Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Melcus/parking-system

10 stars
2 code files
View Melcus/parking-system on GitHub

app/Observers/ReservationObserver.php

Open in GitHub
use 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 GitHub
use App\Models\Reservation;
use App\Observers\ReservationObserver;
use Illuminate\Support\ServiceProvider;
 
class AppServiceProvider extends ServiceProvider
{
//
public function boot()
{
Reservation::observe(ReservationObserver::class);
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.