<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Attributes\Guarded;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes;

#[Guarded([])]
class Exam extends Model
{
    use SoftDeletes;

    public static function active($query)
    {
        return $query->where('is_active', true);
    }

  
    public function scopePopular($query)
    {
        return $query->where('is_popular', true);
    }

    protected function casts(): array
    {
        return [
            'fee' => 'decimal:2',
            'sections' => 'array',
            'is_popular' => 'boolean',
            'is_active' => 'boolean',
        ];
    }



    public function scholarships(): BelongsToMany
    {
        return $this->belongsToMany(Scholarship::class, 'exam_scholarship')->withPivot('minimum_score')->withTimestamps();
    }
}
