Support the ongoing development of Laravel.io →
Security Requests
Last updated 2 years ago.
0

You can access route parameters within your filter via first closure's parameter ($route).

In your case this code would probably do what you want:

Route::any('/{id}', array(
    'before' => 'auth|ownWed', // we don't pass $id here
    'as' => 'wedding',
    'uses' => 'WeddingController@main'
))->where('id', '[0-9]+');

Route::filter('ownWed', function($route) {
    // the $route variable passed to this closure contains
    // current route object which has all the info you want
    echo 'id parameter in route = ' . $route->getParameter('id');
});
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

tzookb tzookb Joined 9 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.