CourseWork/app/Http/Middleware/AdminAction.php
2024-06-22 23:59:16 +04:00

27 lines
579 B
PHP

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