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


PHP Role::findOrFail方法代码示例

本文整理汇总了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'));
 }
开发者ID:meccado,项目名称:acl-admin-control-panel,代码行数:14,代码来源:MenuController.php

示例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;
 }
开发者ID:thaigialai1987,项目名称:qlcv,代码行数:8,代码来源:Mymail.php

示例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');
 }
开发者ID:appzcoder,项目名称:laravel-admin,代码行数:16,代码来源:RolesController.php

示例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');
 }
开发者ID:guenthertheilen,项目名称:laravel-boilerplate,代码行数:16,代码来源:RolesController.php

示例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');
 }
开发者ID:amolkattel,项目名称:Asset-Mgnt-Project,代码行数:16,代码来源:RolesController.php

示例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');
 }
开发者ID:misterebs,项目名称:cmsku,代码行数:9,代码来源:UserController.php

示例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');
 }
开发者ID:serovvitaly,项目名称:kotik,代码行数:17,代码来源:RoleController.php

示例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();
 }
开发者ID:nguyenvanduocit,项目名称:Laravel-Source-Account-Manager,代码行数:10,代码来源:RoleController.php

示例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');
 }
开发者ID:seahouse,项目名称:hxerp,代码行数:17,代码来源:RolesController.php

示例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();
 }
开发者ID:abreban,项目名称:RGU,代码行数:18,代码来源:RoleController.php

示例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;
 }
开发者ID:thaigialai1987,项目名称:qlcv,代码行数:11,代码来源:Controller.php

示例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);
 }
开发者ID:hydrosolutions,项目名称:irrigation-calculator,代码行数:13,代码来源:RoleController.php

示例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');
     }
 }
开发者ID:archer3cl,项目名称:adhl,代码行数:20,代码来源:RoleController.php

示例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'));
 }
开发者ID:ConsoleTVs,项目名称:Laralum,代码行数:16,代码来源:RolesController.php

示例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;
     }
 }
开发者ID:intothesource,项目名称:users,代码行数:22,代码来源:RolesRequest.php


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