ramadanproject/app/Console/Commands/ExpireReservations.php
Ahmed Darrazi 45a147253c
Some checks failed
tests / ci (push) Failing after 6m13s
linter / quality (pull_request) Failing after 58s
linter / quality (push) Failing after 1m19s
tests / ci (pull_request) Failing after 5m28s
feat(public-grid): add QA, quickstart, decision docs; scheduler docs; ignore files; tasks updates; run pint
2026-01-03 04:56:12 +01:00

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;
}
}