本文整理匯總了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());
}