Gadaian overall reports

This commit is contained in:
Afiq Hamzah
2023-11-23 11:09:18 +08:00
committed by Afiq Hamzah
parent abbf7b7691
commit 91ca24d23f
26 changed files with 2229 additions and 1 deletions
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace App;
use DateTime;
use Illuminate\Support\Facades\DB;
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");
}
public static function getActiveCawanganDbConnection()
{
$all_active_db_keys = array_filter(array_keys(config('database.connections')), function ($connection) {
try {
DB::connection($connection)->getPdo();
return true;
} catch (\Throwable $th) {
return false;
}
});
$non_cawangan_database = ['lelong', 'online_arrahn', 'kaunterpkb'];
$all_cawangan_db = array_filter($all_active_db_keys, function ($db_key) use ($non_cawangan_database) {
$isNotCawangan = in_array(config('database.connections.' . $db_key . '.database'), $non_cawangan_database);
if ($isNotCawangan) {
return false;
}
return true;
});
return $all_cawangan_db;
}
}