<?php

declare(strict_types=1);

namespace App\Models;

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

class AcademyAiComparisonResult extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'lesson_block_id',
        'provider',
        'model_name',
        'image_path',
        'thumb_path',
        'settings',
        'strengths',
        'weaknesses',
        'best_for',
        'score',
        'sort_order',
        'active',
    ];

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

    public function block(): BelongsTo
    {
        return $this->belongsTo(AcademyLessonBlock::class, 'lesson_block_id');
    }

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

    public function scopeOrdered(Builder $query): Builder
    {
        return $query->orderBy('sort_order')->orderBy('id');
    }
}
