mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 20:44:19 +00:00
102 lines
3.4 KiB
PHP
102 lines
3.4 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\MorphMany;
|
|
use Spatie\Activitylog\Models\Activity;
|
|
|
|
/**
|
|
* App\Models\Transport
|
|
*
|
|
* @property int $id
|
|
* @property string $owner_type
|
|
* @property int $owner_id
|
|
* @property int $type
|
|
* @property string|null $courier
|
|
* @property string|null $tracking_number
|
|
* @property \Illuminate\Support\Carbon|null $dispatch_date
|
|
* @property \Illuminate\Support\Carbon|null $drop_date
|
|
* @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|Activity[] $activities
|
|
* @property-read int|null $activities_count
|
|
* @property-read Model|\Eloquent $causer
|
|
* @property-read Model|\Eloquent $owner
|
|
* @property-read Collection|Schedule[] $schedules
|
|
* @property-read int|null $schedules_count
|
|
* @property-read Model|\Eloquent $subject
|
|
* @property-read Model|\Eloquent $target
|
|
* @method static Builder|Transport dispatched()
|
|
* @method static Builder|Transport dropped()
|
|
* @method static Builder|Transport newModelQuery()
|
|
* @method static Builder|Transport newQuery()
|
|
* @method static \Illuminate\Database\Query\Builder|Transport onlyTrashed()
|
|
* @method static Builder|Transport query()
|
|
* @method static Builder|Transport whereCourier($value)
|
|
* @method static Builder|Transport whereCreatedAt($value)
|
|
* @method static Builder|Transport whereDeletedAt($value)
|
|
* @method static Builder|Transport whereDispatchDate($value)
|
|
* @method static Builder|Transport whereDropDate($value)
|
|
* @method static Builder|Transport whereId($value)
|
|
* @method static Builder|Transport whereOwnerId($value)
|
|
* @method static Builder|Transport whereOwnerType($value)
|
|
* @method static Builder|Transport whereStatus($value)
|
|
* @method static Builder|Transport whereTrackingNumber($value)
|
|
* @method static Builder|Transport whereType($value)
|
|
* @method static Builder|Transport whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Query\Builder|Transport withTrashed()
|
|
* @method static \Illuminate\Database\Query\Builder|Transport withoutTrashed()
|
|
* @mixin \Eloquent
|
|
*/
|
|
class Transport extends AbstractModel
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'transport_arrangements';
|
|
|
|
protected $fillable = ['status', 'drop_date'];
|
|
|
|
protected $dates = ['dispatch_date', 'drop_date'];
|
|
|
|
/**
|
|
* @return MorphTo
|
|
*/
|
|
public function owner(): morphTo
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
|
|
/**
|
|
* @return MorphMany
|
|
*/
|
|
public function schedules(): morphMany
|
|
{
|
|
return $this->morphMany(Schedule::class, 'owner');
|
|
}
|
|
|
|
/**
|
|
* @param $query
|
|
* @return mixed
|
|
*/
|
|
public function scopeDispatched($query){
|
|
return $query->where('dispatch_date', '<', Carbon::now())->whereIn('status', [ApprovalStatus::APPROVED]);
|
|
}
|
|
|
|
/**
|
|
* @param $query
|
|
* @return mixed
|
|
*/
|
|
public function scopeDropped($query){
|
|
return $query->where('drop_date', '<', Carbon::now())->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
|
}
|
|
}
|