當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。