当前位置: 首页>>代码示例>>PHP>>正文


PHP Permission::whereName方法代码示例

本文整理汇总了PHP中app\Permission::whereName方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::whereName方法的具体用法?PHP Permission::whereName怎么用?PHP Permission::whereName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Permission的用法示例。


在下文中一共展示了Permission::whereName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addPermission

 /**
  * Add a Permission to a Role
  *
  * @param mixed $permission Permission to add, might by instance of Permission or name of permission as string
  * @return Illuminate\Database\Eloquent\Model
  */
 public function addPermission($permission)
 {
     if (is_string($permission)) {
         $permission = Permission::whereName($permission)->firstOrFail();
     }
     return $this->permissions()->save($permission);
 }
开发者ID:guenthertheilen,项目名称:laravel-boilerplate,代码行数:13,代码来源:Role.php

示例2: postGiveRolePermissions

 /**
  * Store given permissions to role.
  *
  * @param  \Illuminate\Http\Request  $request
  *
  * @return void
  */
 public function postGiveRolePermissions(Request $request)
 {
     $this->validate($request, ['role' => 'required', 'permissions' => 'required']);
     $role = Role::with('permissions')->whereName($request->role)->first();
     $role->permissions()->detach();
     foreach ($request->permissions as $permission_name) {
         $permission = Permission::whereName($permission_name)->first();
         $role->givePermissionTo($permission);
     }
     Session::flash('flash_message', 'Permission granted!');
     return redirect('admin/roles');
 }
开发者ID:appzcoder,项目名称:laravel-admin,代码行数:19,代码来源:AdminController.php

示例3: postUserRolePermissions

 /**
  * Store given permissions to role.
  *
  * @param  \Illuminate\Http\Request  $request
  *
  * @return void
  */
 public function postUserRolePermissions(Request $request)
 {
     $this->validate($request, ['role' => 'required', 'permissions' => 'required']);
     $role = Role::with('permissions')->whereName($request->role)->first();
     $role->permissions()->detach();
     foreach ($request->permissions as $permission_name) {
         $permission = Permission::whereName($permission_name)->first();
         $role->assign($permission);
     }
     \Session::flash('flash_message', 'Permission granted!');
     return \Redirect::route('admin.assign-role-permissions', []);
 }
开发者ID:meccado,项目名称:acl-admin-control-panel,代码行数:19,代码来源:AdminController.php

示例4: thePermissionWithTheNameHasTheRoleWithTheName

 /**
  * @Given the permission with the name :arg1 has the role with the name :arg2
  */
 public function thePermissionWithTheNameHasTheRoleWithTheName($arg1, $arg2)
 {
     $permission = Permission::whereName($arg1)->firstOrFail();
     $role = Role::whereName($arg2)->firstOrFail();
     $permission->addRole($role);
 }
开发者ID:guenthertheilen,项目名称:laravel-boilerplate,代码行数:9,代码来源:FeatureContext.php


注:本文中的app\Permission::whereName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。