<?php

declare(strict_types=1);

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;

final class QuestionGroup extends Model
{
    use HasFactory;

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

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

    /**
     * Get the category that owns this question group.
     */
    public function category(): BelongsTo
    {
        return $this->belongsTo(Category::class);
    }

    /**
     * Get all questions for this question group.
     */
    public function questions(): HasMany
    {
        return $this->hasMany(Question::class);
    }
}
