feat: redirect trip form to dashboard, distinguish cancellation sources, and add lightweight real-time polling

This commit is contained in:
Ray1111-aa
2026-10-22 16:13:24 +07:00
parent a1c0042eb1
commit 84f93b7bd6
10 changed files with 659 additions and 25 deletions
+37
View File
@@ -93,6 +93,43 @@ class VehicleActivity extends Model
return $this->validation_status === 'cancelled';
}
/**
* Cek apakah pembatalan dilakukan otomatis oleh sistem (timeout > 5 jam).
*/
public function isCancelledBySystem(): bool
{
if ($this->validation_status !== 'cancelled') {
return false;
}
$note = strtolower((string) $this->rejection_note);
return str_contains($note, 'sistem') || str_contains($note, 'timeout') || str_contains($note, 'melebihi batas');
}
/**
* Cek apakah pembatalan dilakukan mandiri oleh pengguna / driver.
*/
public function isCancelledByUser(): bool
{
return $this->validation_status === 'cancelled' && !$this->isCancelledBySystem();
}
/**
* Label sumber pembatalan yang deskriptif dan ramah pengguna.
*/
public function getCancellationSourceLabelAttribute(): string
{
if ($this->isCancelledBySystem()) {
return 'Batal Sistem (Timeout)';
}
if ($this->isCancelledByUser()) {
return 'Dibatalkan Pengemudi';
}
return 'Dibatalkan';
}
public function isRejected(): bool
{
return $this->validation_status === 'rejected';