how i can call filter in filter using laravel?
i have this filter:
Route::filter('auth', function()
{
if (Auth::guest())
{
if (Request::ajax())
{
return Response::make('Unauthorized', 401);
}
else
{
return Redirect::guest('login');
}
}
});
now i create another filter called admin and i want call auth filter in this:
Route::filter('admin', function(){
#call auth filter
#code
});
it's possible do that?
Using callRouteFilter()
method in Illuminate\\Routing\\RouteFiltererInterface
as @Dwight suggested:
Route::filter('admin', function ($route, $request) {
if ($r = Route::callRouteFilter('auth', array(), $route, $request)) {
return $r;
}
});
Try using the callRouteFilter() method
.
Route::filter('admin', function()
{
Route::callRouteFilter('auth');
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.