get(); // Menghapus atribut yang terkait dengan "enter" foreach ($peminjaman as $peminjamanItem) { unset($peminjamanItem->enter_at); unset($peminjamanItem->enter_pic); unset($peminjamanItem->enter_warehouse); unset($peminjamanItem->kondisi_peti); } return ResponseFormatter::success([ 'message' => 'Data peminjaman berhasil diambil', 'asset_status' => $peminjaman, ]); } public function getWarehouseEnter() { $warehouse = \App\Models\m_warehouse::get(); return ResponseFormatter::success([ 'message' => 'Data warehouse berhasil diambil', 'warehouse' => $warehouse, ]); } public function show($id) { $peminjaman = asset_status::with(['peti.customer', 'peti.tipe_peti', 'warehouse'])->find($id); return ResponseFormatter::success([ 'message' => 'Data peminjaman berhasil diambil ID', 'asset_status' => $peminjaman ]); } public function store(Request $request) { $mobile_id = $request->input('mobile_id'); $peti_id = $request->input('peti_id'); $exit_at = $request->input('exit_at'); $exit_pic = $request->input('exit_pic'); $exit_warehouse = $request->input('exit_warehouse'); $est_pengembalian = $request->input('est_pengembalian'); // $status = $request->input('status'); $created_by = $request->input('created_by'); $created_at = $request->input('created_at'); $existingRecord = asset_status::where('mobile_id', $mobile_id) ->where('peti_id', $peti_id) ->first(); if ($existingRecord) { $existingRecord->exit_at = $exit_at; $existingRecord->exit_pic = $exit_pic; $existingRecord->exit_warehouse = $exit_warehouse; $existingRecord->est_pengembalian = $est_pengembalian; // $existingRecord->status = $status; $existingRecord->created_by = $created_by; $existingRecord->created_at = $created_at; $existingRecord->save(); return ResponseFormatter::success([ 'message' => 'Data peminjaman berhasil ditambahkan', 'peminjam' => $existingRecord ]); } else { $newRecord = new asset_status; $newRecord->mobile_id = $mobile_id; $newRecord->peti_id = $peti_id; $newRecord->exit_at = $exit_at; $newRecord->exit_pic = $exit_pic; $newRecord->exit_warehouse = $exit_warehouse; $newRecord->est_pengembalian = $est_pengembalian; // $newRecord->status = $status; $newRecord->created_by = $created_by; $newRecord->created_at = $created_at; $newRecord->save(); return ResponseFormatter::success([ 'message' => 'Data peminjaman berhasil ditambahkan', 'peminjam' => $newRecord ]); } } }