<?php

namespace App\Models\Claim;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

class Status extends Model {
    protected $fillable = [
        'display_name',
        'description',
        'colour',
        'sort_order',
    ];

    public function claims() {
        return $this->hasMany(Claim::class);
    }

    public function hasClaims(): bool {
        return $this->claims()->exists();
    }

    protected static function boot() {
        parent::boot();
        static::addGlobalScope('order', function (Builder $builder) {
            $builder->orderBy('sort_order');
        });
    }
}