当前位置: 首页>>代码示例>>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;未经允许,请勿转载。