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


PHP Permission::find方法代码示例

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


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

示例1: save

 public function save(Request $request)
 {
     $as = $request->input('as');
     $permission = new Permission();
     $validator = \Validator::make($request->all(), $permission->getRules());
     $results = new \StdClass();
     if ($validator->passes()) {
         if ($request->input('id') != "xxx") {
             $permission = Permission::find($request->input('id'));
             $permission->name = $request->input('name');
             $permission->display_name = $request->input('displayname');
             $permission->description = $request->input('description');
             $permission->save();
             $results->info = 'permission create';
         } else {
             $permission = new Permission();
             $permission->name = $request->input('name');
             $permission->display_name = $request->input('displayname');
             $permission->description = $request->input('description');
             $permission->save();
             $results->info = 'permission edit';
         }
         $results->status = 1;
         $results->result = $permission;
     } else {
         $results->status = 0;
         $result = array();
         foreach ($validator->errors() as $key => $err) {
             array_push($result, $err);
         }
         $results->result = $result;
     }
     return response()->json($results);
 }
开发者ID:shofyanugraha,项目名称:egor,代码行数:34,代码来源:PermissionController.php

示例2: putAddpermission

 public function putAddpermission($id)
 {
     $rol = Role::find($id);
     $per = Permission::find(Request::input('permission_id'));
     $rol->attachPermission($per);
     return $per;
 }
开发者ID:bluesky777,项目名称:5myvc,代码行数:7,代码来源:RolesController.php

示例3: postLearn

 public function postLearn(Request $request)
 {
     $permission = Permission::find($request->input('permission_id'));
     $permission->learning_user_id = $request->input('user_id');
     $permission->save();
     return redirect('/');
 }
开发者ID:reportingsjr,项目名称:makerspace-manager,代码行数:7,代码来源:AdminController.php

示例4: revokePermission

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

示例5: show

 /**
  * Display the specified resource.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function show($id)
 {
     $permission = Permission::find($id);
     if (is_null($permission)) {
         throw new NotFoundException();
     }
     return response()->item($permission, new PermissionTransformer());
 }
开发者ID:TolotraRam,项目名称:laravel-angular-cms,代码行数:15,代码来源:PermissionController.php

示例6: delete

 /**
  * Delete permission
  * 
  * @param int $id
  * @throws SaveException
  */
 public static function delete($id)
 {
     try {
         $permission = PermissionModel::find($id);
         $permission->delete();
     } catch (Exception $e) {
         throw $e;
     }
 }
开发者ID:jasekz,项目名称:filament-for-laravel-5,代码行数:15,代码来源:Permission.php

示例7: destroy

 public function destroy($id)
 {
     $permissions = Permission::find($id);
     if ($permissions->id != 1) {
         $permissions->delete();
         return redirect()->action('Admin\\PermissionsController@index');
     } else {
         return redirect()->action('Admin\\PermissionsController@index')->with('error', 'Something went wrong.');
     }
 }
开发者ID:aArenar54rus,项目名称:bookcross,代码行数:10,代码来源:PermissionsController.php

示例8: find

 /**
  * @param  $id
  * @param  bool                                                                             $withRoles
  * @throws GeneralException
  * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Support\Collection|null|static
  */
 public function find($id, $withRoles = false)
 {
     if (!is_null(Permission::find($id))) {
         if ($withRoles) {
             return Permission::with('roles')->find($id);
         }
         return Permission::find($id);
     }
     throw new GeneralException('That permission does not exist.');
 }
开发者ID:aysenli,项目名称:laravel5-backend,代码行数:16,代码来源:PermissionRepository.php

示例9: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Permission::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'category', $this->category]);
     $query->orderBy('category');
     return $dataProvider;
 }
开发者ID:aruna470,项目名称:sdim,代码行数:21,代码来源:PermissionSearch.php

示例10: testStore

 public function testStore()
 {
     echo "\n\nPERMISSION CONTROLLER TEST\n\n";
     $this->withoutMiddleware();
     $this->call('POST', '/permission', $this->permissionRolesMapping);
     $permission1 = Permission::find(1);
     $permission2 = Permission::find(2);
     $permission3 = Permission::find(3);
     $role1 = Role::find(1);
     $role2 = Role::find(2);
     $this->assertTrue($permission1->hasRole($role1->name));
     $this->assertTrue($permission2->hasRole($role2->name));
     $this->assertTrue($permission3->hasRole($role2->name));
     $this->assertFalse($permission3->hasRole($role1->name));
     $this->assertFalse($permission1->hasRole($role2->name));
     // todo: sort this failing
     // $this->assertRedirectedToRoute('permission.index');
 }
开发者ID:echiteri,项目名称:iBLIS,代码行数:18,代码来源:PermissionControllerTest.php

示例11: destroy

 public function destroy($id)
 {
     Permission::find($id)->delete();
     return redirect()->route('admin.permissions.index');
 }
开发者ID:phelipperibeiro,项目名称:book_store_laravel,代码行数:5,代码来源:PermissionsController.php

示例12: update

 public function update($id, UpdatePermissionRequest $request)
 {
     $permission = Permission::find($id);
     $permission->update($request->all());
     return redirect()->route('permissions.show', $id)->with('successes', ['Permission updated successfully']);
 }
开发者ID:pinkynrg,项目名称:convergence2.0,代码行数:6,代码来源:PermissionsController.php

示例13: getPermissionById

 public function getPermissionById($id)
 {
     return Permission::find($id);
 }
开发者ID:lufias,项目名称:L5admin,代码行数:4,代码来源:PermissionRepository.php

示例14: permissions

 public function permissions(Request $request)
 {
     try {
         $permission = Permission::find($request->get('permission_id'));
         $role = Role::find($request->get('role_id'));
         $role->givePermissionTo($permission);
         Flash::success('The permission "' . $permission->permission_name . '" was successfully assigned to the role "' . $role->role_name . '"');
     } catch (\Exception $e) {
         Flash::danger('The relationship you specified already exists: ' . $e->getMessage());
     }
     return back();
 }
开发者ID:scotthummel,项目名称:lambdaphx,代码行数:12,代码来源:RoleController.php

示例15: destroy

 /**
  * Remove the specified Permission from storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     /** @var Permission $permissions */
     $permission = Permission::find($id);
     if (empty($permission)) {
         Flash::error('Permissions not found');
         return redirect(route('admin.permissions.index'));
     }
     $permission->delete();
     Flash::message('Permission deleted successfully.');
     return redirect(route('admin.permissions.index'));
 }
开发者ID:jclyons52,项目名称:mycourse-rocks,代码行数:19,代码来源:AdminPermissionsController.php


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