feat: add 5-hour trip expiration timer and rbac activity deletion permissions

This commit is contained in:
Ray1111-aa
2026-10-22 12:23:13 +07:00
parent d389e0a9c2
commit 34c9310e8a
14 changed files with 753 additions and 27 deletions
@@ -0,0 +1,42 @@
<?php
namespace App\Console\Commands;
use App\Models\VehicleActivity;
use Illuminate\Console\Command;
class ExpirePendingActivitiesCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'activities:expire-pending {--hours=5 : Batas maksimal jam menunggu verifikasi}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Batalkan otomatis tiket perjalanan pending yang melebihi batas waktu verifikasi (default 5 jam)';
/**
* Execute the console command.
*/
public function handle(): int
{
$hours = (int) $this->option('hours');
if ($hours <= 0) {
$hours = VehicleActivity::PENDING_TIMEOUT_HOURS;
}
$this->info("Memeriksa tiket perjalanan pending yang berusia lebih dari {$hours} jam...");
$affected = VehicleActivity::expireOverduePendingActivities($hours);
$this->info("Selesai: Sebanyak {$affected} tiket perjalanan berhasil dibatalkan otomatis.");
return Command::SUCCESS;
}
}