67 lines
1.5 KiB
PHP
67 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Modules\Tms\Models;
|
|
|
|
use App\Contact;
|
|
use App\Transaction;
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class CustomsClearance extends Model
|
|
{
|
|
protected $table = 'tms_customs_clearances';
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected $casts = [
|
|
'customs_value' => 'decimal:4',
|
|
'duty_amount' => 'decimal:4',
|
|
'vat_amount' => 'decimal:4',
|
|
'other_charges' => 'decimal:4',
|
|
'total_duties' => 'decimal:4',
|
|
'declared_at' => 'datetime',
|
|
'cleared_at' => 'datetime',
|
|
'released_at' => 'datetime',
|
|
];
|
|
|
|
public function shipment()
|
|
{
|
|
return $this->belongsTo(Shipment::class, 'shipment_id');
|
|
}
|
|
|
|
public function transaction()
|
|
{
|
|
return $this->belongsTo(Transaction::class, 'transaction_id');
|
|
}
|
|
|
|
public function contact()
|
|
{
|
|
return $this->belongsTo(Contact::class, 'contact_id');
|
|
}
|
|
|
|
public function broker()
|
|
{
|
|
return $this->belongsTo(CustomsBroker::class, 'broker_id');
|
|
}
|
|
|
|
public function creator()
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
|
|
public function items()
|
|
{
|
|
return $this->hasMany(CustomsItem::class, 'customs_clearance_id');
|
|
}
|
|
|
|
public function documents()
|
|
{
|
|
return $this->hasMany(CustomsDocument::class, 'customs_clearance_id');
|
|
}
|
|
|
|
public function statusLogs()
|
|
{
|
|
return $this->hasMany(CustomsStatusLog::class, 'customs_clearance_id')->orderByDesc('logged_at');
|
|
}
|
|
}
|