jeudi 14 janvier 2016

Laravel 5.1 ACL route resource not working

After following a tutorial on how the built-in acl of laravel works I tried it and it works well by defining every route by itself.

Now I'm trying to use a resource but it's not working as intended. I added the following code to my routes file:

Route::group(['middleware' => 'acl:create_client'], function()
{
    Route::resource('clients', 'ClientController');
});

Now I understand what the problem is:

all the methods in the Clientcontroller will be checked against my db if this user has the acl:create_client, resulting in all methods available to the logged in user that has this acl.

How do I split every method to use it's own acl without having to write it like this:

Route::get('/client/create', [
    'middleware' => 'acl:create_client',
    'as' => 'clients.create',
    'uses' => 'ClientController@create'
]);

Resulting in something like this:

create needs create_client

index needs index_client

update need update_client

etc etc



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire