An action filter for each method in the Laravel controller

I am creating a fairly extensive application for the client, and I will need to create some kind of control over group permissions. I decided to go with Cartalyst and their Sentry package .
So far so good!

Now the problem that I am facing is the best way to detect the permission of a group of users, since there are more than one of them, so I can’t just use one filter and do it with it.

For example, I would do something like this:

For pages requiring admin access

Route::group(array('before' => 'is_admin'), function()
{
       Route::get('admin', array('as'=>'admin', 'uses'=>'admin@index'));
       // Other methods that require admin-level access
});

For pages that need moretaor access, etc.

Route::group(array('before' => 'is_moderator'), function()

    {
           Route::get('orodja/plosca', array('as'=>'moderator', 'uses'=>'moderator@index'));
           // Other methods that require moderator-level access
    });

, , .

Controller::detect() REST-full, , , . , .?

, :. , .

!

+5
1

, URI (. )

Route::filter('pattern: admin/*', 'auth');

:

$this->filter('before', 'auth')->only(array('index', 'list'));

, . Route::controller('admin::home');, .

, auth , .

+7

All Articles