85 lines
2.2 KiB
PHP
85 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
use MatanYadaev\EloquentSpatial\Objects\Point;
|
|
use MatanYadaev\EloquentSpatial\Traits\HasSpatial;
|
|
|
|
class TripTimelineEvent extends Model
|
|
{
|
|
use HasFactory, HasSpatial;
|
|
|
|
public const TYPE_TRIP_STARTED = 'trip_started';
|
|
|
|
public const TYPE_ARRIVED_AT_STOP = 'arrived_at_stop';
|
|
|
|
public const TYPE_COLLECTION_STARTED = 'collection_started';
|
|
|
|
public const TYPE_QR_SCANNED = 'qr_scanned';
|
|
|
|
public const TYPE_COLLECTION_COMPLETED = 'collection_completed';
|
|
|
|
public const TYPE_DEPARTED_STOP = 'departed_stop';
|
|
|
|
public const TYPE_STOP_SKIPPED = 'stop_skipped';
|
|
|
|
public const TYPE_TRUCK_FULL_WARNING = 'truck_full_warning';
|
|
|
|
public const TYPE_ARRIVED_AT_DUMPSITE = 'arrived_at_dumpsite';
|
|
|
|
public const TYPE_LOAD_RELEASED = 'load_released';
|
|
|
|
public const TYPE_DEPARTED_DUMPSITE = 'departed_dumpsite';
|
|
|
|
public const TYPE_TRIP_COMPLETED = 'trip_completed';
|
|
|
|
public const TYPE_INCIDENT_REPORTED = 'incident_reported';
|
|
|
|
public const TYPE_BREAKDOWN = 'breakdown';
|
|
|
|
public const TYPE_DETOUR_TO_DUMPSITE = 'detour_to_dumpsite';
|
|
|
|
public const TYPE_RESUMED_FROM_DETOUR = 'resumed_from_detour';
|
|
|
|
public const TYPE_CONTINUATION_CREATED = 'continuation_created';
|
|
|
|
public $timestamps = false;
|
|
|
|
protected $dateFormat = 'Y-m-d H:i:s';
|
|
|
|
protected $fillable = [
|
|
'trip_id', 'event_type', 'event_at', 'coordinates',
|
|
'recorded_by_user_id', 'related_type', 'related_id',
|
|
'metadata', 'notes', 'created_at',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'event_at' => 'datetime',
|
|
'created_at' => 'datetime',
|
|
'coordinates' => Point::class,
|
|
'metadata' => 'array',
|
|
];
|
|
}
|
|
|
|
public function trip(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Trip::class);
|
|
}
|
|
|
|
public function recordedBy(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'recorded_by_user_id');
|
|
}
|
|
|
|
public function related(): MorphTo
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
}
|