<?php

declare(strict_types=1);

namespace App\Models;

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

final class Category extends Model
{
    use HasFactory;

    /**
     * Fillable attributes for mass assignment.
     */
    protected $fillable = [
        'name',
        'sort_order',
    ];

    /**
     * Cast attributes to specific types.
     */
    protected function casts(): array
    {
        return [
            'sort_order' => 'integer',
        ];
    }

    /**
     * Get all question groups for this category.
     */
    public function questionGroups(): HasMany
    {
        return $this->hasMany(QuestionGroup::class);
    }

    /**
     * Get all sessions for this category.
     */
    public function sessions(): HasMany
    {
        return $this->hasMany(Session::class);
    }
}
