Laravel Gate定义澄清

时间:2017-11-07 13:25:37

标签: php laravel laravel-5.5

我有2个角色

Reward Manager// Allows Super Admin and User Profile Manager all user-management actions but denies all reward related. Gate::define('user-management', function ($user) { return ($user->hasRole('Super Admin') || $user->hasRole('User Profile Manager')); }); // Allow Super Admin and Reward Manager all reward-management but denies all user related. Gate::define('reward-management', function ($user) { return ($user->hasRole('Super Admin') || $user->hasRole('Reward Manager')) ; });

用户个人资料管理器可以访问所有与用户相关的操作,但不能与奖励相关。

奖励经理可以访问一些与用户相关的但与之相关的所有奖励。

我定义了以下门

Route::group(['middleware' => 'can:user-management'], function() {

    Route::get('users/getusers', 'UserController@getUsers');
    Route::post('sendnotification', 'UserController@sendNotification');

});
Route::group(['middleware' => 'can:reward-management'], function() {

    Route::get('users/getRewardPoints/{userId}', 'UserController@getRewardPoints');
    Route::post('users/manageRewardPoints', 'UserController@manageRewardPoints');

});

我的路线及其中间件在下面给出。

"{'group_by':'gender'}"

我想以我上面解释过的方式重写这个。我怎样才能做到这一点?我是以正确的方式做到的吗?

0 个答案:

没有答案