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


PHP Role::whereCanParentForBoard方法代码示例

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


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

示例1: putAdd

 /**
  * Add a new role.
  *
  * @param  \App\Board  $board
  * @return Response
  */
 public function putAdd(Board $board)
 {
     if (!$this->user->canEditConfig($board)) {
         return abort(403);
     }
     $roles = Role::whereCanParentForBoard($board, $this->user)->get();
     $castes = $board->getRoleCastes(Input::get('roleType'))->get()->pluck('caste');
     $rules = ['roleType' => ["required", "string", "in:" . $roles->lists('role')->implode(",")], 'roleCaste' => ["string", "alpha_num", "unique:roles,role,{$board->board_uri},board_uri"], 'roleName' => ["string"], 'roleCapcode' => ["string"]];
     $validator = Validator::make(Input::all(), $rules);
     $validator->sometimes('roleCaste', "not_in:" . $castes->implode(","), function ($input) use($castes) {
         return $castes->count();
     });
     if ($validator->fails()) {
         return redirect()->back()->withInput()->withErrors($validator->errors());
     }
     $role = new Role();
     $role->board_uri = $board->board_uri;
     $role->inherit_id = $roles->where('role', strtolower(Input::get('roleType')))->pluck('role_id')[0];
     $role->role = strtolower(Input::get('roleType'));
     $role->caste = strtolower(Input::get('roleCaste'));
     $role->name = Input::get('roleName') ?: "user.role.{$role->role}";
     $role->capcode = Input::get('roleCapcode');
     $role->weight = 5 + constant(Role::class . "::WEIGHT_" . strtoupper(Input::get('roleType')));
     $role->save();
     return redirect($role->getPermissionsURLForBoard());
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:32,代码来源:RolesController.php


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