<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class DocumentType extends Model
{
    protected $fillable = ['name', 'slug', 'is_active', 'sorting'];

    protected $casts = [
        'is_active' => 'boolean',
    ];

    public function generalDocuments(): HasMany
    {
        return $this->hasMany(GeneralDocument::class);
    }

    public function scopeActive($query)
    {
        return $query->where('is_active', true)->orderBy('sorting');
    }
}
