本文整理汇总了PHP中app\Role::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::findOrFail方法的具体用法?PHP Role::findOrFail怎么用?PHP Role::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Role
的用法示例。
在下文中一共展示了Role::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
if (\Auth::user()->roles[0]->can('menu-delete')) {
$this->menus->findOrFail($id)->delete();
return \Redirect::route('admin.menus.index', [])->withMessage(trans('acl::menu.menus-controller-successfully_deleted'));
}
return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));
}
示例2: getroleemail
public static function getroleemail($userid)
{
$role_id = User::where('id', $userid)->value('role_id');
$role = Role::findOrFail($role_id);
$chucnang = 'thuden';
$rolechucnangs = RoleChucnang::join('danhmucchucnangs', 'role_chucnangs.danhmucchucnang_id', '=', 'danhmucchucnangs.id')->where('role_id', $role->id)->where('danhmucchucnangs.chucnang_id', $chucnang)->select('danhmucchucnangs.id', 'role_chucnangs.role_id', 'role_chucnangs.danhmucchucnang_id', 'role_chucnangs.Danhsach', 'role_chucnangs.Xem', 'role_chucnangs.Them', 'role_chucnangs.Sua', 'role_chucnangs.Xoa', 'danhmucchucnangs.tenchucnang', 'danhmucchucnangs.chucnang_id', 'danhmucchucnangs.orders', 'danhmucchucnangs.level')->first();
return $rolechucnangs;
}
示例3: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @param \Illuminate\Http\Request $request
*
* @return void
*/
public function update($id, Request $request)
{
$this->validate($request, ['name' => 'required']);
$role = Role::findOrFail($id);
$role->update($request->all());
Session::flash('flash_message', 'Role updated!');
return redirect('admin/roles');
}
示例4: update
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\EditRoleRequest $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(EditRoleRequest $request, $id)
{
$this->authorize('roles-edit');
$role = Role::findOrFail($id);
$role->update($request->all());
$permissions = empty($request->permissions) ? [] : $request->permissions;
$role->permissions()->sync($permissions);
return redirect('roles');
}
示例5: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
$this->validate($request, ['name' => 'required|unique:roles,id,' . $id . '|max:255', 'label' => 'required|unique:roles,id,' . $id . '|max:255']);
$role = Role::findOrFail($id);
$role->update($request->all());
$this->syncPermissions($role, $request->input('permission_list'));
flash()->success('Success!', 'Role has been updated!');
return redirect('roles');
}
示例6: updateRole
public function updateRole($id, Request $request)
{
$role = Role::findOrFail($id);
$permission_id = $request->permission_id ? $request->permission_id : [];
$role->permissions()->sync($permission_id);
flash()->message('修改成功!');
return redirect()->back();
// return redirect('admin/users/roles');
}
示例7: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
if (!$this->user->userCan('role-edit')) {
\App::abort(403, 'Access denied');
}
$role_model = \App\Role::findOrFail($id);
$role_model->update($request->all());
$role_model->permissions()->sync($request->get('permissions', []));
return redirect('/admin/role');
}
示例8: destroy
public function destroy($roleId)
{
try {
$role = Role::findOrFail($roleId);
$role->delete();
} catch (Exception $e) {
Session::flash('message', 'Fail : ' . $e->getMessage());
}
return Redirect::back();
}
示例9: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(RoleRequest $request, $id)
{
//
$role = Role::findOrFail($id);
$role->name = $request->input('name');
$role->display_name = $request->input('display_name');
$role->description = $request->input('description');
$role->update();
return redirect('system/roles');
}
示例10: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$role = Role::findOrFail($id);
$this->validate($request, ['name' => 'required|max:255', 'label' => 'required|max:255']);
$input = $request->all();
$role->label = $request->label;
$role->name = $request->name;
$role->save();
Session::flash('flash_message', 'Role updated!');
return redirect()->back();
}
示例11: rolechucnangs
protected function rolechucnangs($chucnang)
{
$userid = Auth::user()->id;
//Cookie::make('userfolder', Auth::user()->username);
Cookie::queue(Cookie::make('userfolder', Auth::user()->username, 5));
$role_id = User::where('id', $userid)->value('role_id');
$role = Role::findOrFail($role_id);
$this->menus = $role->danhmuchucnangs()->orderBy('orders')->orderBy('tenchucnang')->get();
$rolechucnangs = RoleChucnang::join('danhmucchucnangs', 'role_chucnangs.danhmucchucnang_id', '=', 'danhmucchucnangs.id')->where('role_id', $role->id)->where('danhmucchucnangs.chucnang_id', $chucnang)->select('danhmucchucnangs.id', 'role_chucnangs.role_id', 'role_chucnangs.danhmucchucnang_id', 'role_chucnangs.Danhsach', 'role_chucnangs.Xem', 'role_chucnangs.Them', 'role_chucnangs.Sua', 'role_chucnangs.Xoa', 'danhmucchucnangs.tenchucnang', 'danhmucchucnangs.chucnang_id', 'danhmucchucnangs.orders', 'danhmucchucnangs.level')->first();
return $rolechucnangs;
}
示例12: postDelete
public function postDelete(Request $request)
{
$role = Role::findOrFail($request->get('id'));
$arr = array('id' => $role->id, 'name' => $role->name);
if ($role->delete()) {
$message = trans('language.ROLE-DELETED');
// Logging::deleted('Role', $arr);
} else {
$message = trans('language.ROLE-NOT-DELETED');
// Logging::not_deleted('Role', $arr);
}
return redirect()->route('admin-roles-list')->with('global', $message);
}
示例13: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
$user = User::findOrFail($id);
$role = Role::findOrFail(Input::get('role'));
if (!$user->hasRole($role->name)) {
$user->detachRoles($user->roles);
$user->attachRole($role);
Notification::success('Al usuario <strong>' . $user->name . '</strong> se le asigno el rol <strong>' . $role->display_name . '</strong>');
return redirect('roles');
} else {
return redirect('roles');
}
}
示例14: update
public function update($id, Request $request)
{
Laralum::permissionToAccess('laralum.roles.access');
# Check permissions
Laralum::permissionToAccess('laralum.roles.edit');
# Find the row
$row = Role::findOrFail($id);
if (!$row->allow_editing and !Laralum::loggedInuser()->su) {
abort(403, trans('laralum.error_editing_disabled'));
}
# Save the data
$data_index = 'roles';
require 'Data/Edit/Save.php';
# Return the admin to the users page with a success message
return redirect()->route('Laralum::roles')->with('success', trans('laralum.msg_role_edited'));
}
示例15: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
switch ($this->method()) {
case 'GET':
case 'DELETE':
return [];
case 'POST':
return ['name' => 'required|min:3|max:255|unique:roles,name'];
case 'PUT':
case 'PATCH':
$id = $this->route()->roles;
$role = Role::findOrFail($id);
return ['name' => 'required|min:3|max:255|unique:roles,name,' . $role->id];
default:
break;
}
}