當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。