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