<?php

declare(strict_types=1);

namespace App\Models;

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

final class QuestionBank extends Model
{
    use SoftDeletes;

    protected $fillable = ['owner_id', 'name', 'description', 'visibility', 'is_active'];

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

    public function owner(): BelongsTo
    {
        return $this->belongsTo(User::class, 'owner_id');
    }

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

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

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