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
110 lines
2.6 KiB
PHP
110 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Parking\Setup\Gate;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\ConfigHardware;
|
|
use Illuminate\Http\Request;
|
|
|
|
class MasterGateHardwareController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function create()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*
|
|
* @param int $id
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function show($id)
|
|
{
|
|
// # ambil konfigurasi hardware berdasarkan id_pos (id pintu)
|
|
$gateDetails = ConfigHardware::where('id_pos', $id)->first();
|
|
|
|
// # kalau belum ada datanya, kembalikan objek kosong biar form tetap kebuka
|
|
return response()->json($gateDetails ?? (object) []);
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*
|
|
* @param int $id
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function edit($id)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param int $id
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function update(Request $request, $id)
|
|
{
|
|
// # hanya kolom yang terdaftar di fillable yang boleh disimpan
|
|
$allowed = (new ConfigHardware())->getFillable();
|
|
$data = $request->input('data', []);
|
|
|
|
$filtered = [];
|
|
foreach ((array) $data as $key => $value) {
|
|
if (in_array($key, $allowed, true)) {
|
|
// # ubah string kosong jadi null biar cocok dengan kolom integer
|
|
$filtered[$key] = $value === '' ? null : $value;
|
|
}
|
|
}
|
|
|
|
// # simpan (buat baru kalau id_pos belum punya baris hardware)
|
|
$hardware = ConfigHardware::updateOrCreate(['id_pos' => $id], $filtered);
|
|
|
|
return response()->json([
|
|
'success' => true,
|
|
'message' => 'Konfigurasi hardware berhasil disimpan.',
|
|
'data' => $hardware,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param int $id
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy($id)
|
|
{
|
|
//
|
|
}
|
|
}
|