<?php

namespace App\Models;

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

class Report extends Model
{
    protected $fillable = [
        'slug',
        'name',
        'description',
        'category',
        'enabled',
        'order',
    ];

    protected $casts = [
        'enabled' => 'boolean',
        'order' => 'integer',
    ];

    public function entities(): HasMany
    {
        return $this->hasMany(ReportEntity::class)->orderBy('order');
    }

    public function columns(): HasMany
    {
        return $this->hasMany(ReportColumn::class)->orderBy('order');
    }

    public function filters(): HasMany
    {
        return $this->hasMany(ReportFilter::class)->orderBy('order');
    }

    public function conditions(): HasMany
    {
        return $this->hasMany(ReportCondition::class)->orderBy('order');
    }

    public function orders(): HasMany
    {
        return $this->hasMany(ReportOrder::class)->orderBy('order');
    }
}
