74 lines
2.1 KiB
PHP
74 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Sewa;
|
|
use Illuminate\Http\Request;
|
|
|
|
class VerifikasiController extends Controller
|
|
{
|
|
/**
|
|
* Menampilkan daftar pembayaran yang perlu diverifikasi
|
|
*/
|
|
public function index()
|
|
{
|
|
// Ambil semua sewa yang perlu diverifikasi (status pending dan sudah upload bukti)
|
|
$sewas = Sewa::where('status', 'pending')
|
|
->whereNotNull('bukti_pembayaran')
|
|
->whereNotNull('foto_jaminan')
|
|
->with(['user', 'paket', 'kota'])
|
|
->latest()
|
|
->get();
|
|
|
|
return view('admin.verifikasi-pembayaran', compact('sewas'));
|
|
}
|
|
|
|
/**
|
|
* Menyetujui pembayaran
|
|
*/
|
|
public function approve($id)
|
|
{
|
|
try {
|
|
$sewa = Sewa::findOrFail($id);
|
|
|
|
// Pastikan status masih pending
|
|
if ($sewa->status !== 'pending') {
|
|
return back()->with('error', 'Status sewa tidak valid untuk diverifikasi.');
|
|
}
|
|
|
|
// Update status menjadi confirmed
|
|
$sewa->update([
|
|
'status' => 'confirmed'
|
|
]);
|
|
|
|
return back()->with('success', 'Pembayaran berhasil diverifikasi dan disetujui.');
|
|
} catch (\Exception $e) {
|
|
return back()->with('error', 'Terjadi kesalahan: ' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Menolak pembayaran
|
|
*/
|
|
public function reject($id)
|
|
{
|
|
try {
|
|
$sewa = Sewa::findOrFail($id);
|
|
|
|
// Pastikan status masih pending
|
|
if ($sewa->status !== 'pending') {
|
|
return back()->with('error', 'Status sewa tidak valid untuk ditolak.');
|
|
}
|
|
|
|
// Update status menjadi ditolak
|
|
$sewa->update([
|
|
'status' => 'ditolak'
|
|
]);
|
|
|
|
return back()->with('success', 'Pembayaran telah ditolak.');
|
|
} catch (\Exception $e) {
|
|
return back()->with('error', 'Terjadi kesalahan: ' . $e->getMessage());
|
|
}
|
|
}
|
|
}
|