CourseWork/app/Http/Middleware/TeacherAction.php
m.zargarov d4cabb23b7 Fix
2024-06-24 00:51:05 +04:00

27 lines
585 B
PHP

<?php
namespace App\Http\Middleware;
use App\Models\Teacher;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;
class TeacherAction
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
if (Auth::user()->userable_type != Teacher::class) {
abort(403);
}
return $next($request);
}
}