2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
|
|
|
use Config;
|
|
|
|
use Route;
|
2016-06-02 02:48:52 -07:00
|
|
|
use Gate;
|
2016-03-25 01:18:05 -07:00
|
|
|
|
|
|
|
class CheckPermissions
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Handle the ACLs for permissions.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Closure $next
|
2016-06-02 02:48:52 -07:00
|
|
|
* @param string|null $section
|
2016-03-25 01:18:05 -07:00
|
|
|
* @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', [
|
2016-06-02 02:48:52 -07:00
|
|
|
'content' => view('errors/403')
|
2016-03-25 01:18:05 -07:00
|
|
|
]);
|
|
|
|
|
2016-06-02 02:48:52 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|
|
|
|
}
|