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


PHP Permission::findOrFail方法代码示例

本文整理汇总了PHP中app\Permission::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::findOrFail方法的具体用法?PHP Permission::findOrFail怎么用?PHP Permission::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Permission的用法示例。


在下文中一共展示了Permission::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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']);
     $permission = Permission::findOrFail($id);
     $permission->update($request->all());
     Session::flash('flash_message', 'Permission updated!');
     return redirect('admin/permissions');
 }
开发者ID:appzcoder,项目名称:laravel-admin,代码行数:16,代码来源:PermissionsController.php

示例2: 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:permissions,id,' . $id . '|max:255', 'label' => 'required|unique:permissions,id,' . $id . '|max:255']);
     $permission = Permission::findOrFail($id);
     $permission->update($request->all());
     flash()->success('Success!', 'Permission has been updated!');
     return redirect('permissions');
 }
开发者ID:amolkattel,项目名称:Asset-Mgnt-Project,代码行数:15,代码来源:PermissionsController.php

示例3: update

 /**
  * do edit data
  * @param mixed $request
  * @param int $id
  * @return redirect
  */
 public function update(Request $request, $id)
 {
     $messages = ['name.required' => 'Permission name is necessary!'];
     $this->validate($request, ['name' => 'required'], $messages);
     $permission = Permission::findOrFail($id);
     $permission->update($request->all());
     return redirect(route('admin.permission.index'))->with('info', 'Updated Successfully~~');
 }
开发者ID:Jokeramc,项目名称:amc,代码行数:14,代码来源:PermissionController.php

示例4: 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('permission-edit')) {
         \App::abort(403, 'Access denied');
     }
     $permission_model = \App\Permission::findOrFail($id);
     $permission_model->update($request->all());
     return redirect('/admin/permission');
 }
开发者ID:serovvitaly,项目名称:kotik,代码行数:16,代码来源:PermissionController.php

示例5: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \App\Http\Requests\EditPermissionRequest  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(EditPermissionRequest $request, $id)
 {
     $this->authorize('permissions-edit');
     $permission = Permission::findOrFail($id);
     $permission->update($request->all());
     $roles = empty($request->roles) ? [] : $request->roles;
     $permission->roles()->sync($roles);
     return redirect('permissions');
 }
开发者ID:guenthertheilen,项目名称:laravel-boilerplate,代码行数:16,代码来源:PermissionsController.php

示例6: editPermission

 public function editPermission(Request $request)
 {
     $item = Permission::findOrFail($request->id);
     $item->name = $request->name;
     $item->display_name = $request->display_name;
     $item->description = $request->description;
     $item->save();
     return \Response::make($item, 200);
 }
开发者ID:bunsha,项目名称:gazingle,代码行数:9,代码来源:PermissionsController.php

示例7: update

 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(PermissionRequest $request, $id)
 {
     //
     $permission = Permission::findOrFail($id);
     $permission->name = $request->input('name');
     $permission->display_name = $request->input('display_name');
     $permission->description = $request->input('description');
     $permission->update();
     return redirect('system/permissions');
 }
开发者ID:seahouse,项目名称:hxerp,代码行数:17,代码来源:PermissionsController.php

示例8: update

 public function update(Request $request, $id)
 {
     $permission = Permission::findOrFail($id);
     $this->validate($request, ['name' => 'required|max:255', 'label' => 'required|max:255']);
     $input = $request->all();
     $permission->name = $request->name;
     $permission->label = $request->label;
     $permission->save();
     Session::flash('flash_message', 'Permission updated!');
     return redirect()->back();
 }
开发者ID:abreban,项目名称:RGU,代码行数:11,代码来源:PermissionsController.php

示例9: hasPermission

 public function hasPermission($permission)
 {
     $errors = array_filter($permission);
     if (!empty($errors)) {
         foreach ($values as $value) {
             $permission = Permission::findOrFail($value);
             $this->givePermissionTo($permission);
             return !!$permission->intersect($this->permissions)->count();
         }
     }
 }
开发者ID:nasirkhan,项目名称:laravel-5-starter,代码行数:11,代码来源:Role.php

示例10: addPermission

 public function addPermission(Request $request, $id)
 {
     $this->validate($request, ['permission' => 'required']);
     try {
         $role = Role::findOrFail($id);
         $permission = Permission::findOrFail($request->input('permission'));
         $role->permissions()->save($permission);
         \Session::flash('message-success', 'Permissão adicionada a role: ' . $role->name);
         return redirect()->route('admin::roles::edit', $id);
     } catch (Exception $e) {
         return redirect()->route('admin::roles::list')->withErrors($e->getMessage());
     }
 }
开发者ID:tassianoalencar,项目名称:mercurios-roles,代码行数:13,代码来源:RolesController.php

示例11: edit

 public function edit($id)
 {
     $permission = Permission::findOrFail($id);
     return view('admin.permission.edit', compact('permission'));
 }
开发者ID:nutsdo,项目名称:mz-service,代码行数:5,代码来源:PermissionController.php

示例12: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($roleId, $permissionId)
 {
     //
     $role = Role::findOrFail($roleId);
     $permission = Permission::findOrFail($permissionId);
     if ($role != null && $permission != null) {
         $role->detachPermission($permission);
     } else {
         back();
     }
     return redirect('system/roles/' . $roleId . '/permissions');
 }
开发者ID:seahouse,项目名称:hxerp,代码行数:18,代码来源:RolepermissionsController.php

示例13: canInBoards

 /**
  * Returns a list of direct, extant Board URIs where this permission exists.
  * The goal of this is to weed out loose permissions provided by global permissions.
  *
  * @return array (of board_uri)
  */
 public function canInBoards($permission)
 {
     $boards = [];
     if (!$permission instanceof Permission) {
         $permission = Permission::findOrFail($permission);
     }
     $boardsWithRights = $permission->getBoardsWithPermissions($this, false);
     $boards = [];
     foreach ($boardsWithRights as $board_uri) {
         if (is_null($board_uri) || strlen($board_uri) === 0) {
             continue;
         }
         if ($this->getPermission($permission, $board_uri)) {
             $boards[] = $board_uri;
         }
     }
     return $boards;
 }
开发者ID:tmrwbo,项目名称:infinity-next,代码行数:24,代码来源:PermissionUser.php

示例14: findById

 public function findById($id)
 {
     return \App\Permission::findOrFail($id);
 }
开发者ID:crow1796,项目名称:technologyRIS,代码行数:4,代码来源:PermissionRepository.php

示例15: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $permission = Permission::findOrFail($id);
     $permission->delete();
     return redirect(route('admin.permissions.index'))->with('success', 'The permission has been deleted.');
 }
开发者ID:Shoodey,项目名称:Events,代码行数:12,代码来源:PermissionsController.php


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