Mohamed Bouallegue
Mohamed Bouallegue

Reputation: 1362

Laravel pattern based filter

I'm reading the Laravel documentation and it is saying that it is possible to add a pattern based filter to a route

Route::filter('admin', function()
{
    //
});

Route::when('admin/*', 'admin');

I want to know how to specify if the filter is executed before or after the request?

Upvotes: 1

Views: 382

Answers (1)

Jason Lewis
Jason Lewis

Reputation: 18665

Pattern filters are always called before and cannot be called after a routes execution.

You can see it being called in the source (4.1.24) on GitHub.

A solution to this is to have all your admin routes inside a route group and apply the filter to the entire group.

Upvotes: 2

Related Questions