2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
2023-03-18 11:58:09 -07:00
|
|
|
use Illuminate\Support\Facades\Gate;
|
2016-06-15 21:18:40 -07:00
|
|
|
|
2016-03-25 01:18:05 -07:00
|
|
|
class CheckPermissions
|
|
|
|
{
|
2021-06-10 13:15:52 -07:00
|
|
|
/**
|
|
|
|
* Handle the ACLs for permissions.
|
|
|
|
*
|
|
|
|
* The $section variable is passed via the route middleware,
|
|
|
|
* 'middleware' => [authorize:superadmin']
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Closure $next
|
|
|
|
* @param string|null $section
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2016-06-02 02:48:52 -07:00
|
|
|
public function handle($request, Closure $next, $section = null)
|
2016-03-25 01:18:05 -07:00
|
|
|
{
|
2016-06-02 02:48:52 -07:00
|
|
|
if (Gate::allows($section)) {
|
2016-03-25 01:18:05 -07:00
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
|
|
|
|
return response()->view('layouts/basic', [
|
2021-06-10 13:15:52 -07:00
|
|
|
'content' => view('errors/403'),
|
2024-07-05 03:54:49 -07:00
|
|
|
], 403);
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|
|
|
|
}
|