I currently have an AdminContoller with a constructor method that handles some of the earlier filters. Is there a way to filter before all controller methods except one?
I use Entrust for roles and permissions, but this code throws me into an endless redirection loop. I have not logged in as a user at all. Therefore, this code should redirect me to the URL / admin / login, which is attached to the unfiltered AdminController @adminLogin method. But is that not so?
// File AdminController.php
class AdminController extends BaseController { function __construct() { // Is something like this possible? $this->beforeFilter('admin', array('except' => array('adminLogin'))); $this->beforeFilter('csrf', array('on' => 'post')); } public function index() { return "Admin - Index"; } public function adminLogin() { return "Admin Login Form"; } // ... and many more methods }
// Filter.php File
Route::filter('admin', function() { if( !Entrust::hasRole('admin') )
// Routes.php File
Route::resource('admin', 'AdminController'); Route::get('/admin/login', ' AdminController@adminLogin ');
source share