File: /var/www/html/orbidirectory.com/app/Models/CargoVehicle.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
class CargoVehicle extends Model implements HasMedia
{
use HasFactory, InteractsWithMedia;
protected $fillable = [
'transporter_id',
'cargo_brand_id',
'cargo_model_id',
'cargo_type_id',
'fuel_type',
'body_type',
'loading_ramp_available',
'permit_type',
'weight_capacity',
'weight_unit',
'length_in',
'width_in',
'depth_in',
'bed_dimension_unit',
];
public function registerMediaCollections(): void
{
$this->addMediaCollection('cargo_vehicle_image')->singleFile();
}
public static function goodsTransportCapacityOptions()
{
return [
'below_750' => 'Below 750 Kg',
'above_750' => 'Above 750 Kg',
];
}
const fuel_type = [
'cng' => 'CNG',
'petrol' => 'Petrol',
'diesel' => 'Diesel',
'hybrid' => 'Hybrid',
];
const body_type = [
'open' => 'Open',
'closed' => 'Closed',
];
const loading_ramp_available = [
1 => 'Yes',
0 => 'No',
];
const permit_type = [
'local' => 'Local',
'all_india' => 'All India',
];
const weight_unit = [
'kg' => 'Kg'
];
const bed_dimension_unit = [
'feet' => 'Feet',
];
const status = [
0 => 'Inactive',
1 => 'Active',
2 => 'Banned',
];
const STATUS_INACTIVE = 0;
const STATUS_ACTIVE = 1;
const STATUS_BANNED = 2;
public function transporter()
{
return $this->belongsTo(Transporter::class);
}
public function cargoBrand()
{
return $this->belongsTo(CargoBrand::class, 'cargo_brand_id');
}
public function cargoModel()
{
return $this->belongsTo(CargoModel::class, 'cargo_model_id');
}
public function cargoType()
{
return $this->belongsTo(CargoType::class, 'cargo_type_id');
}
}