44 lines
874 B
PHP
44 lines
874 B
PHP
<?php
|
|
|
|
namespace Modules\Equipments\Models;
|
|
|
|
use App\Traits\HasPublicIdentifier;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
class Equipment extends Model
|
|
{
|
|
use HasPublicIdentifier;
|
|
|
|
protected $table = 'equipments';
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'owner_name',
|
|
'hourly_rate',
|
|
'status',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'hourly_rate' => 'decimal:2',
|
|
];
|
|
}
|
|
|
|
public function scopeActive($query)
|
|
{
|
|
return $query->where('status', 'active');
|
|
}
|
|
|
|
public function specifications(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(
|
|
EquipmentSpecification::class,
|
|
'equipment_specification',
|
|
'equipment_id',
|
|
'specification_id'
|
|
);
|
|
}
|
|
}
|