52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\Tms\Models;
|
|
|
|
use App\BusinessLocation;
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class RoutePlan extends Model
|
|
{
|
|
protected $table = 'tms_routes';
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected $casts = [
|
|
'route_date' => 'date',
|
|
'origin_latitude' => 'decimal:7',
|
|
'origin_longitude' => 'decimal:7',
|
|
'total_distance_km' => 'decimal:2',
|
|
];
|
|
|
|
public function driver()
|
|
{
|
|
return $this->belongsTo(Driver::class, 'driver_id');
|
|
}
|
|
|
|
public function vehicle()
|
|
{
|
|
return $this->belongsTo(Vehicle::class, 'vehicle_id');
|
|
}
|
|
|
|
public function originLocation()
|
|
{
|
|
return $this->belongsTo(BusinessLocation::class, 'origin_location_id');
|
|
}
|
|
|
|
public function stops()
|
|
{
|
|
return $this->hasMany(RouteStop::class, 'route_id')->orderBy('stop_order');
|
|
}
|
|
|
|
public function shipments()
|
|
{
|
|
return $this->hasMany(Shipment::class, 'route_id');
|
|
}
|
|
|
|
public function creator()
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
}
|