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

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.

Sign in to participate in this thread!


Your banner here too?

tzookb tzookb Joined 9 Feb 2014


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

Your logo here?

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

© 2024 - All rights reserved.