Kumpulan perubahan yang udah numpuk di working tree: refactor Setup (Gate/Vehicle/Member), rapihin memberin & stiker, service parking baru (ParkingUtilsServices, NetworkService), model/migration lot-parking & DHCP reservation, dan fitur baru Intercom (controller/model/migration/ view). ReportTransaksiController versi lokal ini WIP (~90%, masih didebug) - versi yang bener ada di server, jadi dikeluarin dari git (ditambahin ke .gitignore) biar gak numpuk nindihin punya server pas git pull di sana. Sekalian keluarin dump mentah tabel softseting (1.8MB, nyasar ke-commit), file .bak, dan arsip ad-hoc (api.tgz, c.zip) yang emang bukan source code. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EAJc2mrpj2cSTe4oowLPzQ
44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Parking;
|
|
|
|
use Illuminate\Support\Facades\Config;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class ParkingUtilsServices
|
|
{
|
|
private function isMirror($user)
|
|
{
|
|
return $user->statusabsen == 1;
|
|
}
|
|
|
|
private function pgConnectSecond($site_config = null)
|
|
{
|
|
try {
|
|
Config::set("database.connections.pgsql_second", [
|
|
"driver" => "pgsql",
|
|
"host" => $site_config->site_host,
|
|
"user" => $site_config->site_user,
|
|
"password" => $site_config->site_password,
|
|
"database" => $site_config->site_database,
|
|
"port" => $site_config->site_port,
|
|
"charset" => "utf8",
|
|
"prefix" => "",
|
|
"schema" => "public",
|
|
]);
|
|
return DB::table("pgsql_second");
|
|
} catch (\Exception $e) {
|
|
Log::error("Failed connect to database " . $e->getMessage());
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public function useTableParkir($user)
|
|
{
|
|
$table = $this->isMirror($user) ? "parkir_transaksi" : "transaksi_parkir";
|
|
|
|
return DB::table("$table as tp");
|
|
}
|
|
}
|