<?php

namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Http\Request;

class Authenticate extends Middleware
{
    protected function redirectTo(Request $request): ?string
    {
        if (! $request->expectsJson()) {
            // Cek guard mana yang dipake
            if ($request->is('admin/*')) {
                return route('admin.login');
            }
            
            if ($request->is('guru/*')) {
                return route('guru.login');
            }
            
            if ($request->is('siswa/*')) {
                return route('siswa.login');
            }
            
            // Default ke landing page
            return route('landing-page');
        }
        
        return null;
    }
}