<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class AcademicYear extends Model
{
    protected $fillable = ['school_id', 'name', 'start_date', 'end_date', 'is_current'];
    protected $casts = ['is_current' => 'boolean', 'start_date' => 'date', 'end_date' => 'date'];

    public function school() { return $this->belongsTo(School::class); }
    public function terms() { return $this->hasMany(Term::class); }
    public function currentTerm() { return $this->hasOne(Term::class)->where('is_current', true); }
}
