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


PHP Permission::findOrFail方法代码示例

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


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

示例1: destroy

 /**
  * Removes the specified permission from the specified role.
  *
  * @param int|string $permissionId
  * @param int|string $roleId
  *
  * @return int
  */
 public function destroy($permissionId, $roleId)
 {
     $this->authorize('admin.roles.permissions.destroy');
     $permission = $this->permission->findOrFail($permissionId);
     $role = $permission->roles()->findOrFail($roleId);
     return $permission->roles()->detach($role);
 }
开发者ID:stevebauman,项目名称:administration,代码行数:15,代码来源:PermissionRoleProcessor.php

示例2: destroy

 /**
  * Removes the specified permission from the specified user.
  *
  * @param int|string $permissionId
  * @param int|string $userId
  *
  * @return int
  */
 public function destroy($permissionId, $userId)
 {
     $this->authorize('admin.users.permissions.destroy');
     $permission = $this->permission->findOrFail($permissionId);
     $user = $permission->users()->findOrFail($userId);
     return $permission->users()->detach($user);
 }
开发者ID:stevebauman,项目名称:administration,代码行数:15,代码来源:PermissionUserProcessor.php

示例3: destroy

 /**
  * Removes the specified permission from the specified user.
  *
  * @param int|string $permissionId
  * @param int|string $userId
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($permissionId, $userId)
 {
     $this->authorize('admin.users.permissions.destroy');
     $permission = $this->permission->findOrFail($permissionId);
     $user = $permission->users()->findOrFail($userId);
     if ($permission->users()->detach($user)) {
         flash()->success('Success!', 'Successfully removed user.');
         return redirect()->route('admin.permissions.show', [$permissionId]);
     }
     flash()->error('Error!', 'There was an issue removing this user. Please try again.');
     return redirect()->route('admin.permissions.show', [$permissionId]);
 }
开发者ID:stevebauman,项目名称:ithub,代码行数:20,代码来源:PermissionUserController.php

示例4: updatePermission

 public function updatePermission($request)
 {
     $id = $request->route('permission');
     $model = Permission::findOrFail($id);
     $model->fill(['name' => $request->name, 'label' => $request->label]);
     return $model->save();
 }
开发者ID:jaumesala,项目名称:opendata-maps,代码行数:7,代码来源:PermissionRepository.php

示例5: storePermission

 public function storePermission(Request $request, $id)
 {
     $role = Role::find($id);
     $permission = Permission::findOrFail($request->all()['permission_id']);
     $role->addPermission($permission);
     return redirect()->back();
 }
开发者ID:phelipperibeiro,项目名称:book_store_laravel,代码行数:7,代码来源:RolesController.php

示例6: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $permission = \App\Models\Permission::findOrFail($id);
     $this->authorize('destroy', $permission);
     $permission->delete();
     return redirect(route('permission.index'));
 }
开发者ID:jaffarhussain1011,项目名称:laravel-authorization-demo,代码行数:13,代码来源:PermissionController.php

示例7: destroy

 /**
  * Deletes the specified permission.
  *
  * @param int|string $id
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($id)
 {
     $this->authorize('admin.permissions.destroy');
     $permission = $this->permission->findOrFail($id);
     if ($permission->delete()) {
         flash()->success('Success!', 'Successfully deleted permission.');
         return redirect()->route('admin.permissions.index');
     }
     flash()->error('Error!', 'There was an error deleting this permission. Please try again.');
     return redirect()->route('admin.permissions.create');
 }
开发者ID:stevebauman,项目名称:ithub,代码行数:18,代码来源:PermissionController.php

示例8: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $data = $request->all();
     $validator = Validator::make($data, ['name' => 'max:255', 'display_name' => 'max:255']);
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $permission = Permission::findOrFail($id);
     $permission->update($data);
     $msg = array('msg' => '已成功更新');
     return json_encode($msg);
 }
开发者ID:nosun,项目名称:laravel_base,代码行数:18,代码来源:PermissionController.php

示例9: store

 /**
  * Store permission
  *
  * @param array $permissionData            
  * @throws NotFoundException, ValidationException
  * @return \App\Models\PermissionModel
  */
 public function store($permissionData)
 {
     try {
         if (array_get($permissionData, 'id')) {
             $permission = PermissionModel::findOrFail((int) array_get($permissionData, 'id'))->fill($permissionData);
         } else {
             $permission = new PermissionModel();
             $permission->fill($permissionData);
         }
     } catch (Exception $e) {
         throw new NotFoundException(trans('app.notFound'));
     }
     if (!$permission->validate()) {
         throw new ValidationException(trans('app.correctErrors'), $permission->errors()->toArray());
     }
     try {
         $permission->save();
     } catch (Exception $e) {
         throw $e;
     }
     return $permission;
 }
开发者ID:jasekz,项目名称:filament-for-laravel-5,代码行数:29,代码来源:Permission.php

示例10: destroy

 /**
  * Deletes the specified permission.
  *
  * @param int|string $id
  *
  * @return bool
  */
 public function destroy($id)
 {
     $this->authorize('admin.permissions.destroy');
     $permission = $this->permission->findOrFail($id);
     return $permission->delete();
 }
开发者ID:stevebauman,项目名称:administration,代码行数:13,代码来源:PermissionProcessor.php

示例11: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $permission = Permission::findOrFail($id);
     $permission->delete();
     Session::flash($this->success, Lang::get('ruban.permission.deleted'));
     return Redirect::route('ruban.permissions.index');
 }
开发者ID:mahitiinfo,项目名称:rubanbridge,代码行数:13,代码来源:PermissionController.php

示例12: deletePermissionsDestroy

 public function deletePermissionsDestroy($id, $permissionid)
 {
     $role = Role::findOrFail($id);
     $permission = Permission::findOrFail($permissionid);
     if ($role->name == 'administrator') {
         return response()->json(['status' => 'failed', 'message' => trans('api.resource_delete_failed_relationship', ['relationship' => trans('global.permission')]), 'errors' => ['name' => [trans('global.role_admin_update_error')]]])->setStatusCode(422);
     }
     if (!$role->hasPermission($permission->name)) {
         abort(404);
     }
     $role->permissions()->detach($permission->id);
     return response()->json(['status' => 'success', 'message' => trans('api.resource_deleted', ['resource' => trans('global.permission')])])->setStatusCode(200);
 }
开发者ID:fluentkit,项目名称:fluentkit,代码行数:13,代码来源:RolesController.php

示例13: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $permission = Permission::findOrFail($id);
     $permission->delete();
     return Redirect::to('admin/permissions');
 }
开发者ID:Zachary-Leung,项目名称:wine_platform,代码行数:12,代码来源:PermissionsController.php

示例14: editPermissions

 public function editPermissions(Request $request)
 {
     $action = $request->input('action');
     if ($action == 'ADD') {
         $permission = new Permission();
         if ($request->input('permissionid') != '') {
             $permission = Permission::find($request->input('permissionid'));
         }
         $permission->name = $request->input('permissionname');
         $permission->display_name = $request->input('permissiondisplay');
         $permission->description = $request->input('permissiondesc');
         $permission->save();
     } elseif ($action == 'DELETE') {
         $permissionId = $request->input('permissionid');
         $permission = Permission::findOrFail($permissionId);
         $permission->delete();
     }
     return redirect('admin/permissions');
 }
开发者ID:gabwhite,项目名称:fsh,代码行数:19,代码来源:AdminController.php


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