CourseWork/app/Http/Middleware/StudentAction.php
2024-06-23 17:02:18 +04:00

27 lines
585 B
PHP

<?php
namespace App\Http\Middleware;
use App\Models\Student;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;
class StudentAction
{
/**
* 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 != Student::class) {
abort(403);
}
return $next($request);
}
}