- 신규 마이그레이션: shipment_vehicle_dispatches 테이블 (seq, logistics_company, arrival_datetime, tonnage, vehicle_no, driver_contact, remarks) - 신규 모델: ShipmentVehicleDispatch (ShipmentItem 패턴 복제) - Shipment 모델: vehicleDispatches() HasMany 관계 추가 - ShipmentService: syncDispatches() 추가, store/update/delete/show/index에서 연동 - FormRequest: Store/Update에 vehicle_dispatches 배열 검증 규칙 추가 - delivery_method 검증에 확장 옵션 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?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',
|
|
];
|
|
|
|
protected $casts = [
|
|
'seq' => 'integer',
|
|
'shipment_id' => 'integer',
|
|
'arrival_datetime' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* 출하 관계
|
|
*/
|
|
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;
|
|
}
|
|
}
|