Laravel 4, how to apply filters on Route::controller()
laravel, laravel-4, php
Solution
In the `constructor` of your controller you may use
public function __construct()
{
$this->beforeFilter('auth');
}
Also, you can use
Route::group(array('before' => 'auth'), function() {
Route::controller(...);
});
Problem
I know i can do this ``` Route::get('foo/bar', array('before' => 'filter', 'uses' => 'Controller@bar')); ``` to apply routes some filter. I am aware of Route::group() method too. Anyway, if i want to define a controller in this way ``` Route::controller('foo/{id}/bar', 'Controller'); ``` i can not pass an array as the 2nd argument. The question: how to apply filters to the following route? ``` Route::controller('foo/{id}/bar', 'Controller'); ``` === EDIT I want to code this in my route.php, not inside a controller constructor.