<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class School extends Model
{
    use HasFactory;

    protected $fillable = [
        'name',
        'code',
        'type',
        'address',
        'city',
        'county',
        'phone',
        'email',
        'logo',
        'status',
        'student_count',
        'teacher_count',
    ];

    // Relationship with Users (School Admins, Teachers, etc.)
    public function users()
    {
        return $this->hasMany(User::class);
    }

    public function schoolAdmins()
    {
        return $this->users()->where('role', 'school_admin');
    }

    public function teachers()
    {
        return $this->users()->where('role', 'teacher');
    }
}