-
app/Observers/ReservationObserver.php
Open in GitHubuse App\Models\Reservation; use Illuminate\Support\Str; class ReservationObserver { public function creating(Reservation $reservation): void { $reservation->uuid = Str::uuid(); Reservation::query() ->whereNull('paid_at') ->where('user_id', $reservation->user_id) ->delete(); } }
-
app/Providers/AppServiceProvider.php
Open in GitHubuse App\Models\Reservation; use App\Observers\ReservationObserver; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { // public function boot() { Reservation::observe(ReservationObserver::class); } }