50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use APP\Models\equipament_type;
|
|
use App\Models\factorie;
|
|
use App\Models\specific_Attributes_Equipament_Type;
|
|
use App\Models\installation;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Equipment extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
public $timestamps = false;
|
|
|
|
protected $table = 'equipments';
|
|
|
|
protected $primaryKey = 'equipment_id';
|
|
|
|
public function unit()
|
|
{
|
|
return $this->belongsTo(Unit::class, 'unit_id', 'unit_id');
|
|
}
|
|
|
|
public function equipmentType()
|
|
{
|
|
return $this->belongsTo(EquipmentType::class, 'equipment_type_id', 'equipment_type_id');
|
|
}
|
|
|
|
// public function specificAttributes()
|
|
// {
|
|
// return $this->hasMany(SpecificAttributesEquipmentType::class, 'equipment_id', 'equipment_id');
|
|
// }
|
|
|
|
public function specificAttributes()
|
|
{
|
|
return $this->hasMany(SpecificAttributesEquipmentType::class, 'equipment_id', 'equipment_id')
|
|
->join('general_attributes_equipaments', 'specific_attributes_equipament_types.general_attributes_equipment_id', '=', 'general_attributes_equipaments.general_attributes_equipment_id')
|
|
->orderBy('general_attributes_equipaments.general_attributes_equipment_description', 'asc');
|
|
}
|
|
|
|
public function equipmentAssociationAmbit()
|
|
{
|
|
return $this->hasMany(EquipmentAssociationAmbit::class, 'equipment_id', 'equipment_id');
|
|
}
|
|
}
|