39 lines
802 B
PHP
39 lines
802 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class ChecklistScope extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'checklist_section_id',
|
|
'code',
|
|
'title',
|
|
'description',
|
|
'order',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'order' => 'integer',
|
|
];
|
|
}
|
|
|
|
public function section(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ChecklistSection::class, 'checklist_section_id');
|
|
}
|
|
|
|
public function items(): HasMany
|
|
{
|
|
return $this->hasMany(ChecklistItem::class)->orderBy('order');
|
|
}
|
|
}
|