<?php

declare(strict_types=1);

namespace App\Models;

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

class AcademyCategory extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'type',
        'name',
        'slug',
        'description',
        'icon',
        'order_num',
        'active',
    ];

    protected $casts = [
        'order_num' => 'integer',
        'active' => 'boolean',
    ];

    public function scopeActive(Builder $query): Builder
    {
        return $query->where('active', true);
    }

    public function lessons(): HasMany
    {
        return $this->hasMany(AcademyLesson::class, 'category_id');
    }

    public function promptTemplates(): HasMany
    {
        return $this->hasMany(AcademyPromptTemplate::class, 'category_id');
    }
}