mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 20:44:01 +00:00
45 lines
939 B
PHP
45 lines
939 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class Schedule extends AbstractModel
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'schedules';
|
|
|
|
protected $dates = ['etd', 'eta'];
|
|
|
|
public function owner(): morphTo
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
|
|
public function transport(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(Transport::class, 'transport_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* @param $query
|
|
* @return mixed
|
|
*/
|
|
public function scopeDispatched($query){
|
|
return $query->where('etd', '<', Carbon::now());
|
|
}
|
|
|
|
/**
|
|
* @param $query
|
|
* @return mixed
|
|
*/
|
|
public function scopeDropped($query){
|
|
return $query->where('eta', '<', Carbon::now());
|
|
}
|
|
}
|