mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 20:44:19 +00:00
86 lines
2.7 KiB
PHP
86 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* App\Models\Schedule
|
|
*
|
|
* @property int $id
|
|
* @property string $owner_type
|
|
* @property int $owner_id
|
|
* @property \Illuminate\Support\Carbon|null $etd
|
|
* @property \Illuminate\Support\Carbon|null $eta
|
|
* @property int $status
|
|
* @property \Illuminate\Support\Carbon|null $deleted_at
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
* @property-read Collection|\Spatie\Activitylog\Models\Activity[] $activities
|
|
* @property-read int|null $activities_count
|
|
* @property-read Model|\Eloquent $causer
|
|
* @property-read Model|\Eloquent $owner
|
|
* @property-read Model|\Eloquent $subject
|
|
* @property-read Model|\Eloquent $target
|
|
* @property-read Transport|null $transport
|
|
* @method static Builder|Schedule dispatched()
|
|
* @method static Builder|Schedule dropped()
|
|
* @method static Builder|Schedule newModelQuery()
|
|
* @method static Builder|Schedule newQuery()
|
|
* @method static \Illuminate\Database\Query\Builder|Schedule onlyTrashed()
|
|
* @method static Builder|Schedule query()
|
|
* @method static Builder|Schedule whereCreatedAt($value)
|
|
* @method static Builder|Schedule whereDeletedAt($value)
|
|
* @method static Builder|Schedule whereEta($value)
|
|
* @method static Builder|Schedule whereEtd($value)
|
|
* @method static Builder|Schedule whereId($value)
|
|
* @method static Builder|Schedule whereOwnerId($value)
|
|
* @method static Builder|Schedule whereOwnerType($value)
|
|
* @method static Builder|Schedule whereStatus($value)
|
|
* @method static Builder|Schedule whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Query\Builder|Schedule withTrashed()
|
|
* @method static \Illuminate\Database\Query\Builder|Schedule withoutTrashed()
|
|
* @mixin \Eloquent
|
|
*/
|
|
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());
|
|
}
|
|
}
|