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;
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With