29 lines
666 B
PHP
29 lines
666 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Reservation;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Console\Command;
|
|
|
|
class ExpireReservations extends Command
|
|
{
|
|
protected $signature = 'reservations:expire';
|
|
|
|
protected $description = 'Expire held reservations that passed their reserved_until timestamp.';
|
|
|
|
public function handle(): int
|
|
{
|
|
$now = Carbon::now();
|
|
|
|
$count = Reservation::where('status', 'held')
|
|
->whereNotNull('reserved_until')
|
|
->where('reserved_until', '<=', $now)
|
|
->update(['status' => 'expired']);
|
|
|
|
$this->info("Expired {$count} reservations.");
|
|
|
|
return 0;
|
|
}
|
|
}
|