Fix helper implementation
Use class with static files instead of load it directly in composer json
This commit is contained in:
@@ -3,14 +3,12 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Cawangan;
|
||||
use App\CawanganDetail;
|
||||
use App\Customer;
|
||||
use App\Gadai;
|
||||
use App\Marhun;
|
||||
use DateTime;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Services\Reports\GadaianService as ReportGadaianService;
|
||||
use App\Helper;
|
||||
|
||||
|
||||
class ReportGadaiController extends Controller
|
||||
{
|
||||
@@ -27,7 +25,7 @@ class ReportGadaiController extends Controller
|
||||
$startDate = $request->startDate;
|
||||
$endDate = $request->endDate;
|
||||
|
||||
$active_cawangan_db_connection = getActiveCawanganDbConnection();
|
||||
$active_cawangan_db_connection = Helper::getActiveCawanganDbConnection();
|
||||
|
||||
$active_cawangan_db_name = array_map(function ($db_connection) {
|
||||
return config('database.connections' . '.' . $db_connection . '.' . 'database');
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Gadai;
|
||||
use App\Marhun;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Helper;
|
||||
|
||||
class GadaianService
|
||||
{
|
||||
@@ -82,8 +83,8 @@ class GadaianService
|
||||
|
||||
$data = [
|
||||
'query' => [
|
||||
'startDate' => formatDate($this->startDate),
|
||||
'endDate' => formatDate($this->endDate),
|
||||
'startDate' => Helper::formatDate($this->startDate),
|
||||
'endDate' => Helper::formatDate($this->endDate),
|
||||
],
|
||||
'cawangan_detail' => $cawangan_detail,
|
||||
'gadaian' => $total_gadaian,
|
||||
|
||||
+12
-16
@@ -1,28 +1,25 @@
|
||||
<?php
|
||||
namespace App;
|
||||
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use DateTime;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
if (!function_exists('formatNumber')) {
|
||||
function formatNumber ($amount) {
|
||||
class Helper
|
||||
{
|
||||
|
||||
public static function formatNumber($amount)
|
||||
{
|
||||
$formattedAmount = number_format($amount, 2, '.', ',');
|
||||
|
||||
return $formattedAmount;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static function formatDate($date_string)
|
||||
{
|
||||
return (new DateTime($date_string))->format("d-m-Y");
|
||||
}
|
||||
|
||||
if (!function_exists('formatDate')) {
|
||||
function formatDate ($date_string) {
|
||||
return (new DateTime($date_string))->format("d-m-Y");
|
||||
};
|
||||
}
|
||||
|
||||
if (!function_exists('getActiveCawanganDbConnection')) {
|
||||
|
||||
function getActiveCawanganDbConnection()
|
||||
public static function getActiveCawanganDbConnection()
|
||||
{
|
||||
|
||||
$all_active_db_keys = array_filter(array_keys(config('database.connections')), function ($connection) {
|
||||
@@ -49,5 +46,4 @@ if (!function_exists('getActiveCawanganDbConnection')) {
|
||||
return $all_cawangan_db;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,9 +21,6 @@
|
||||
"phpunit/phpunit": "^8.5"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"app/helpers.php"
|
||||
],
|
||||
"classmap": [
|
||||
"database/seeds",
|
||||
"database/factories"
|
||||
|
||||
Reference in New Issue
Block a user