CourseWork/app/Http/Middleware/TeacherAction.php

27 lines
585 B
PHP
Raw Permalink Normal View History

2024-06-22 23:59:16 +04:00
<?php
namespace App\Http\Middleware;
2024-06-24 00:51:05 +04:00
use App\Models\Teacher;
2024-06-22 23:59:16 +04:00
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
{
2024-06-24 00:51:05 +04:00
if (Auth::user()->userable_type != Teacher::class) {
2024-06-22 23:59:16 +04:00
abort(403);
}
return $next($request);
}
}