56 lines
1.1 KiB
PHP
56 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\Maintenance\Models;
|
|
|
|
use App\Business;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class ChecklistTemplate extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'maintenance_checklist_templates';
|
|
|
|
protected $fillable = [
|
|
'business_id',
|
|
'equipment_category_id',
|
|
'equipment_id',
|
|
'name',
|
|
'description',
|
|
'is_active',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_active' => 'boolean',
|
|
];
|
|
|
|
protected static function booted(): void
|
|
{ }
|
|
|
|
public function business()
|
|
{
|
|
return $this->belongsTo(Business::class);
|
|
}
|
|
|
|
public function category()
|
|
{
|
|
return $this->belongsTo(EquipmentCategory::class, 'equipment_category_id');
|
|
}
|
|
|
|
public function equipment()
|
|
{
|
|
return $this->belongsTo(Equipment::class, 'equipment_id');
|
|
}
|
|
|
|
public function items()
|
|
{
|
|
return $this->hasMany(ChecklistItem::class, 'template_id')->orderBy('sort_order');
|
|
}
|
|
|
|
public function responses()
|
|
{
|
|
return $this->hasMany(ChecklistResponse::class, 'template_id');
|
|
}
|
|
}
|