Last active
August 29, 2015 14:13
-
-
Save byjujohn/c0ec383d79b92c49e531 to your computer and use it in GitHub Desktop.
Laravel 4 - Passing parameters to class based filters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// app/roues.php | |
Route::group(array('before' => 'myfilter.filtername:value1,value2'), function() { | |
// Routing logic | |
}); | |
// app/filters.php | |
Route::filter('myfilter.filtername', 'MyCustomFilterClassNameFilter@filtermethodFilter'); | |
// MyCustomFilterClassNameFilter.php | |
class MyCustomFilterClassNameFilter { | |
public function filtermethodFilter($route, $request, $param1, $param2) | |
{ | |
// $param1 now holds 'value1' and $param2 holds 'value2' | |
// Filter logic | |
} | |
} | |
// app/roues.php | |
Route::group(array('before' => 'myfilter.filtername:value1,value2'), function() { | |
// Routing logic | |
}); | |
// app/filters.php | |
Route::filter('myfilter.filtername', 'MyCustomFilterClassNameFilter@filtermethodFilter'); | |
// MyCustomFilterClassNameFilter.php | |
class MyCustomFilterClassNameFilter { | |
public function filtermethodFilter($route, $request, $param1, $param2) | |
{ | |
// $param1 now holds 'value1' and $param2 holds 'value2' | |
// Filter logic | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment