<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class EnsureSchoolIsActive
{
    public function handle(Request $request, Closure $next): Response
    {
        $school = $request->user()?->school;

        if ($school && $school->status !== 'active') {
            abort(403, 'مدرسه فعال نیست.');
        }

        return $next($request);
    }
}
