2026-03-04 10:13:16 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models\Tenants;
|
|
|
|
|
|
|
|
|
|
use App\Traits\Auditable;
|
|
|
|
|
use App\Traits\BelongsToTenant;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
|
|
|
|
class ShipmentVehicleDispatch extends Model
|
|
|
|
|
{
|
|
|
|
|
use Auditable, BelongsToTenant, SoftDeletes;
|
|
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'tenant_id',
|
|
|
|
|
'shipment_id',
|
|
|
|
|
'seq',
|
|
|
|
|
'logistics_company',
|
|
|
|
|
'arrival_datetime',
|
|
|
|
|
'tonnage',
|
|
|
|
|
'vehicle_no',
|
|
|
|
|
'driver_contact',
|
|
|
|
|
'remarks',
|
2026-03-04 23:31:04 +09:00
|
|
|
'options',
|
2026-03-04 10:13:16 +09:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'seq' => 'integer',
|
|
|
|
|
'shipment_id' => 'integer',
|
|
|
|
|
'arrival_datetime' => 'datetime',
|
2026-03-04 23:31:04 +09:00
|
|
|
'options' => 'array',
|
2026-03-04 10:13:16 +09:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 출하 관계
|
|
|
|
|
*/
|
|
|
|
|
public function shipment(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Shipment::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 다음 순번 가져오기
|
|
|
|
|
*/
|
|
|
|
|
public static function getNextSeq(int $shipmentId): int
|
|
|
|
|
{
|
|
|
|
|
$maxSeq = static::where('shipment_id', $shipmentId)->max('seq');
|
|
|
|
|
|
|
|
|
|
return ($maxSeq ?? 0) + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|