Bentrok Jadwal

This commit is contained in:
hildaaaevs 2025-06-23 11:36:24 +07:00
parent d550527c36
commit 1e5e982a5f
1 changed files with 14 additions and 0 deletions

View File

@ -59,6 +59,20 @@ protected static function booted()
} catch (\Exception $e) {
Log::error('Gagal mengirim notifikasi email: ' . $e->getMessage());
}
// Otomatis reject reservasi lain yang bentrok
$paketFotoIds = $reservasi->detail()->pluck('paket_foto_id')->toArray();
$reservasiBentrok = self::where('id', '!=', $reservasi->id)
->where('tanggal', $reservasi->tanggal)
->where('waktu', $reservasi->waktu)
->where('status_pembayaran', 'pending')
->whereHas('detail', function($q) use ($paketFotoIds) {
$q->whereIn('paket_foto_id', $paketFotoIds);
})
->get();
foreach ($reservasiBentrok as $r) {
$r->update(['status_pembayaran' => 'rejected']);
}
}
});
}