I created a middleware as:
use Closure;
use Gate;
class ACLMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Gate::denies('access-post')) {
abort(403,'Not allowed!!!');
}
return $next($request);
}
}
And then define in route as:
Route::get('/', 'HomeController@index');
Route::group(['middleware' => 'auth','acl'], function () {
Route::resource('post', 'PostController');
...
When I run this.. it's applying on all routes, even on /
. Why is like that?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire