From 22b9694588f8eabddaac868d6a0035ae80cdcc27 Mon Sep 17 00:00:00 2001 From: micko samawa Date: Mon, 29 Jun 2026 08:07:03 +0700 Subject: [PATCH] feat(admin): add payment verification flow for bookings --- .../Http/Controllers/BookingController.php | 35 +++++++++++++++++++ .../views/admin/bookings/index.blade.php | 13 +++++++ .../views/admin/bookings/show.blade.php | 15 ++++++++ spk_kontrakan/routes/web.php | 1 + 4 files changed, 64 insertions(+) diff --git a/spk_kontrakan/app/Http/Controllers/BookingController.php b/spk_kontrakan/app/Http/Controllers/BookingController.php index fd895b7..cb3d091 100644 --- a/spk_kontrakan/app/Http/Controllers/BookingController.php +++ b/spk_kontrakan/app/Http/Controllers/BookingController.php @@ -566,6 +566,34 @@ public function togglePaymentStatus(Request $request, Booking $booking) } } + /** + * Verifikasi pembayaran (status verification -> paid) + */ + public function verifyPayment(Request $request, Booking $booking) + { + // ========== AUTHORIZATION =========== + $admin = auth()->guard('admin')->user(); + if ($admin) { + if ($booking->kontrakan->admin_id !== $admin->id) { + abort(403, 'Anda tidak memiliki akses ke booking ini.'); + } + } + + // Only allow verification when status is verification + if ($booking->payment_status !== 'verification') { + return back()->with('error', 'Status pembayaran bukan verifikasi.'); + } + + $method = $request->input('payment_method', 'cash'); + $booking->update([ + 'payment_status' => 'paid', + 'payment_method' => $method, + 'paid_at' => now(), + ]); + + return back()->with('success', 'Pembayaran berhasil diverifikasi dan ditandai lunas.'); + } + /** * Hapus booking */ @@ -579,6 +607,13 @@ public function destroy(Booking $booking) } } + $admin = auth()->guard('admin')->user(); + if ($admin) { + if ($booking->kontrakan->admin_id !== $admin->id) { + abort(403, 'Anda tidak memiliki akses ke booking ini.'); + } + } + // delete() akan trigger boot()->deleted() yang auto sync status kontrakan $booking->delete(); diff --git a/spk_kontrakan/resources/views/admin/bookings/index.blade.php b/spk_kontrakan/resources/views/admin/bookings/index.blade.php index f96d9fd..4bbacbf 100644 --- a/spk_kontrakan/resources/views/admin/bookings/index.blade.php +++ b/spk_kontrakan/resources/views/admin/bookings/index.blade.php @@ -189,6 +189,19 @@ {{ $booking->payment_status_label }} + @if($booking->payment_status == 'verification') +
+ @csrf + + +
+ @endif @if($booking->payment_proof) diff --git a/spk_kontrakan/resources/views/admin/bookings/show.blade.php b/spk_kontrakan/resources/views/admin/bookings/show.blade.php index e00016d..fbe8421 100644 --- a/spk_kontrakan/resources/views/admin/bookings/show.blade.php +++ b/spk_kontrakan/resources/views/admin/bookings/show.blade.php @@ -290,6 +290,21 @@ class="btn btn-sm btn-outline-success mt-1"> @endif + @if($booking->payment_status == 'verification') +
+ @csrf +
+ + +
+
+ @endif @endif {{-- Cancel --}} diff --git a/spk_kontrakan/routes/web.php b/spk_kontrakan/routes/web.php index 0ea373f..17228d7 100644 --- a/spk_kontrakan/routes/web.php +++ b/spk_kontrakan/routes/web.php @@ -146,6 +146,7 @@ Route::post('/{booking}/cancel', [BookingController::class, 'cancel'])->name('cancel'); Route::post('/{booking}/mark-paid', [BookingController::class, 'markPaid'])->name('mark-paid'); Route::post('/{booking}/toggle-payment', [BookingController::class, 'togglePaymentStatus'])->name('toggle-payment'); + Route::post('/{booking}/verify-payment', [BookingController::class, 'verifyPayment'])->name('verify-payment'); // API & History Route::post('/check-availability', [BookingController::class, 'checkAvailability'])->name('check-availability');