Support the ongoing development of Laravel.io →
Configuration Architecture
Last updated 1 year ago.
0

check your $request in the filter

I believe

$request->get('id');

should give you the id

your before should look like

....
'before'    => 'maxId',
....
Last updated 1 year ago.
0

Hi zenry,

these calls work:

$route->getParameter('id')
Route::input('id')

As long as

$request->get('id')

return null.

But I would like to know if there a way to pass an argument directly within the filter, since the filter method accept a third parameter....

Surely there must be a way....

Last updated 1 year ago.
0
class MaxIdFilter {

   public function filter( $route , $request ) {

      if ($route->getParameter('id') > 200) {

         return Redirect::route('home', array('error' => 'maxid'));
      }
   }
}
Last updated 1 year ago.
0

what I would like to do, is use the route for "send" the parameter at the filter through use of this syntax:

Route::get('/{id}', array(

    'as'        => 'idhandler',
    'before'    => 'maxId:HERE_ID_PARAMETER',
    'uses'      => 'IdController@showDataId'

));

instead, the examples shown so far, take the parameter directly in the filter class through method calls:

$route->getParameter('id')
Route::input('id')
Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

matiux matiux Joined 28 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.