當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Role::permissions方法代碼示例

本文整理匯總了PHP中app\Role::permissions方法的典型用法代碼示例。如果您正苦於以下問題:PHP Role::permissions方法的具體用法?PHP Role::permissions怎麽用?PHP Role::permissions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Role的用法示例。


在下文中一共展示了Role::permissions方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: updatePermissions

 /**
  * Assign permissions to role
  */
 public function updatePermissions(Request $request, Role $role)
 {
     $permissions = $request->checkedPermissions ?: [];
     // $permissions = array of submitted permissions OR if all checkboxes were unchecked, make it an empty array
     $role->permissions()->sync($permissions);
     logThis('Permissions for ' . $role->label . ' changed to ' . $role->permissions()->lists('label'));
     return $role->load('permissions');
 }
開發者ID:goatatwork,項目名稱:access2,代碼行數:11,代碼來源:RolesApiController.php

示例2: store

 /**
  * Method for stroring a new role in the database.
  *
  * @param RoleRequest $request
  * @return mixed
  */
 public function store(RoleRequest $request)
 {
     $role = new Role($request->all());
     $role->save();
     if (is_null($request->get('permissions'))) {
         $role->permissions()->sync([]);
     } else {
         $role->permissions()->sync($request->get('permissions'));
     }
     return redirect(route('rbac.roles.index'))->withSuccess('You have successfully created a new role.');
 }
開發者ID:JimiOhrid,項目名稱:shopStore,代碼行數:17,代碼來源:RolesController.php

示例3: seedDataSource

 /**
  * Seed Data Source
  *
  * @author EB
  * @return void
  */
 protected function seedDataSource()
 {
     Model::unguard();
     $role = new \App\Role();
     $role->name = 'rosu';
     $role->display_name = 'Read Only Super User';
     $role->description = 'Read only user who can see everything';
     $role->save();
     $permissions = ['merchants-view', 'users-view', 'roles-view', 'locations-view', 'applications-view', 'reports-view'];
     foreach ($permissions as $permission) {
         try {
             $perm = \App\Permission::where('name', '=', $permission)->first();
             $role->permissions()->sync([$perm->id], false);
         } catch (Exception $e) {
         }
     }
     Model::reguard();
 }
開發者ID:paybreak,項目名稱:basket,代碼行數:24,代碼來源:ReadOnlySuperUserSeeder.php

示例4: syncPermissions

 /**
  * Sync up the list of permissions
  * @param  User $user
  * @param  array   $permissions
  * @return void
  */
 private function syncPermissions(Role $role, array $permissions)
 {
     $role->permissions()->sync($permissions);
 }
開發者ID:amolkattel,項目名稱:Asset-Mgnt-Project,代碼行數:10,代碼來源:RolesController.php


注:本文中的app\Role::permissions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。