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


PHP Permission::all方法代码示例

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


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

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $role = Role::whereName(Role::getAdministratorName())->firstOrFail();
     Permission::all()->map(function ($permission) use($role) {
         $role->grant($permission);
     });
 }
开发者ID:stevebauman,项目名称:ithub,代码行数:12,代码来源:ApplyPermissionsSeeder.php

示例2: putAll

 /**
  * Handle permissions change
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function putAll(Request $request)
 {
     $permissions = Permission::all();
     $input = array_keys($request->input('permissions'));
     try {
         DB::beginTransaction();
         $permissions->each(function ($permission) use($input) {
             if (in_array($permission->id, $input)) {
                 $permission->allow = true;
             } else {
                 $permission->allow = false;
             }
             $permission->save();
         });
         DB::commit();
         flash()->success(trans('permissions.save_success'));
     } catch (\Exception $e) {
         var_dump($e->getMessage());
         die;
         flash()->error(trans('permissions.save_error'));
     }
     try {
         Cache::tags(['permissions'])->flush();
     } catch (\Exception $e) {
         Cache::flush();
     }
     return redirect()->back();
 }
开发者ID:Denniskevin,项目名称:Laravel5Starter,代码行数:34,代码来源:AdminPermissionsController.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $list = Permission::all();
     $list = $this->buildTree($list);
     $title = '权限管理';
     return view('admin.permissionList', array('title' => $title, 'list' => $list));
 }
开发者ID:nosun,项目名称:laravel_base,代码行数:12,代码来源:PermissionController.php

示例4: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $administrator = Role::firstOrCreate(['name' => 'administrator', 'label' => 'Administrator']);
     // Welcome Permissions
     Permission::firstOrCreate(['name' => 'admin.welcome.index', 'label' => 'View Administrator Welcome']);
     // User Permissions
     Permission::firstOrCreate(['name' => 'admin.users.index', 'label' => 'View All Users']);
     Permission::firstOrCreate(['name' => 'admin.users.create', 'label' => 'Create Users']);
     Permission::firstOrCreate(['name' => 'admin.users.edit', 'label' => 'Edit Users']);
     Permission::firstOrCreate(['name' => 'admin.users.show', 'label' => 'View Users']);
     Permission::firstOrCreate(['name' => 'admin.users.destroy', 'label' => 'Delete Users']);
     // Role Permissions
     Permission::firstOrCreate(['name' => 'admin.roles.index', 'label' => 'View All Roles']);
     Permission::firstOrCreate(['name' => 'admin.roles.create', 'label' => 'Create Roles']);
     Permission::firstOrCreate(['name' => 'admin.roles.edit', 'label' => 'Edit Roles']);
     Permission::firstOrCreate(['name' => 'admin.roles.show', 'label' => 'View Roles']);
     Permission::firstOrCreate(['name' => 'admin.roles.destroy', 'label' => 'Delete Roles']);
     // Permission Permissions
     Permission::firstOrCreate(['name' => 'admin.permissions.index', 'label' => 'View All Permissions']);
     Permission::firstOrCreate(['name' => 'admin.permissions.create', 'label' => 'Create Permissions']);
     Permission::firstOrCreate(['name' => 'admin.permissions.edit', 'label' => 'Edit Permissions']);
     Permission::firstOrCreate(['name' => 'admin.permissions.show', 'label' => 'View Permissions']);
     Permission::firstOrCreate(['name' => 'admin.permissions.destroy', 'label' => 'Delete Permissions']);
     // User Permission Permissions
     Permission::firstOrCreate(['name' => 'admin.users.permissions.store', 'label' => 'Add Permissions to Users']);
     Permission::firstOrCreate(['name' => 'admin.users.permissions.destroy', 'label' => 'Remove Permissions from Users']);
     // Role Permission Permissions
     Permission::firstOrCreate(['name' => 'admin.roles.permissions.store', 'label' => 'Add Permissions to Roles']);
     Permission::firstOrCreate(['name' => 'admin.roles.permissions.destroy', 'label' => 'Remove Permissions from Roles']);
     // Role User Permissions
     Permission::firstOrCreate(['name' => 'admin.roles.users.store', 'label' => 'Add Users to Roles']);
     Permission::firstOrCreate(['name' => 'admin.roles.users.destroy', 'label' => 'Remove Users from Roles']);
     $administrator->grant(Permission::all());
 }
开发者ID:stevebauman,项目名称:administration,代码行数:39,代码来源:2014_10_12_300000_seed_roles_and_permissions.php

示例5: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $roles = Role::all();
     $permissions = Permission::all();
     $usersWithRoles = User::with('roles')->orderBy('last_name')->get();
     return view('admin.roles.index', ['roles' => $roles, 'permissions' => $permissions, 'users' => $usersWithRoles]);
 }
开发者ID:scotthummel,项目名称:lambdaphx,代码行数:12,代码来源:RoleController.php

示例6: getAllPermission

 public function getAllPermission($sortActions = false)
 {
     $permissions = $this->groupPermissionByResource(Permission::all());
     if (!$sortActions) {
         return $permissions;
     }
     return $this->sortActions($permissions);
 }
开发者ID:lufias,项目名称:L5admin,代码行数:8,代码来源:PermissionRepository.php

示例7: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $data[$this->permissions] = Permission::all();
     $data['createbtn'] = Permission::hasPermission('permissions.create');
     $data['editbtn'] = Permission::hasPermission('permissions.edit');
     $data['deletebtn'] = Permission::hasPermission('permissions.delete');
     return view('permissions.index', $data);
 }
开发者ID:mahitiinfo,项目名称:rubanbridge,代码行数:13,代码来源:PermissionController.php

示例8: edit

 public function edit($id)
 {
     $role = Role::findOrFail($id);
     $permissions = Permission::all();
     $permission = new Permission();
     $permissionRole = $permission->permissionRole($role->id);
     return view('admin.role.edit', ['role' => $role, 'permissions' => $permissions, 'permissionRole' => $permissionRole]);
 }
开发者ID:cdandy,项目名称:meta-admin,代码行数:8,代码来源:RoleController.php

示例9: pget

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function pget($id)
 {
     $role = Role::where('id', '=', $id)->first();
     $list = Permission::all();
     $list = $this->buildTree($list);
     $perms = array();
     foreach ($role->perms as $row) {
         $perms[] = $row->id;
     }
     $title = '权限设置';
     return view('admin.permissionShow', array('title' => $title, 'list' => $list, 'perms' => $perms, 'id' => $id));
 }
开发者ID:nosun,项目名称:laravel_base,代码行数:18,代码来源:RoleController.php

示例10: edit

 /**
  * @param $id
  *
  * @return \Illuminate\View\View
  */
 public function edit($id)
 {
     $user = $this->user->find($id);
     $page_title = trans('admin/users/general.page.edit.title');
     // "Admin | User | Edit";
     $page_description = trans('admin/users/general.page.edit.description', ['full_name' => $user->full_name]);
     // "Editing user";
     if (!$user->isEditable()) {
         abort(403);
     }
     $roles = $this->role->all();
     $perms = $this->perm->all();
     //        $roleCollection = \App\Models\Role::take(10)->get(['id', 'display_name'])->lists('display_name', 'id');
     //        $roleList = [''=>''] + $roleCollection->all();
     return view('admin.users.edit', compact('user', 'roles', 'perms', 'page_title', 'page_description'));
 }
开发者ID:RachidBourougaa,项目名称:laravel-5.1-enterprise-starter-kit,代码行数:21,代码来源:UsersController.php

示例11: getAddMenu

 public function getAddMenu($parent)
 {
     // echo PHP_EOL, "The recognized text is:", $text, PHP_EOL;
     //Log::info(Route::current()->all());
     // Log::info(Route::getCurrentRoute()->getPath());
     //Log::info($parent);
     Session::set('cur', $parent);
     $parents = DB::table('permissions')->where('parent', 0)->get();
     $permission = Permission::all();
     $inputRole = "<select id='col5' class='small m-wrap' tabindex='1'>";
     $inputRole = $inputRole . "<option value='0'>Root</option>";
     foreach ($parents as $parent) {
         $inputRole = $inputRole . '<option value=' . $parent->id . '>' . $parent->display_name . '</option>';
     }
     $inputRole = $inputRole . "</select>";
     Log::info($inputRole);
     return view('user.add_menu', ['permission' => $permission, 'inputRole' => $inputRole]);
 }
开发者ID:alkindiisda,项目名称:laravel,代码行数:18,代码来源:UserManagementController.php

示例12: edit

 public function edit()
 {
     foreach (Route::getRoutes() as $value) {
         if (strpos($value->getName(), "admin.") !== false) {
             try {
                 $displayName = ucwords(strtolower(str_replace(".", " ", str_replace("admin.", "", $value->getName()))));
                 $permissions = new Permission();
                 $permissions->name = $value->getName();
                 $permissions->display_name = $displayName;
                 $permissions->save();
             } catch (\Illuminate\Database\QueryException $e) {
             }
         }
     }
     $permissions = Permission::all();
     $role = Role::find(Input::get('id'));
     $action = "admin.roles.save";
     return view(Config('constants.adminRoleView') . '.addEdit', compact('permissions', 'role', 'action'));
 }
开发者ID:sushilcs111,项目名称:td,代码行数:19,代码来源:RolesController.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(PermissionRequest $request)
 {
     $arrayPermissionRoleMapping = $request->permissionRoles;
     $permissions = Permission::all();
     $roles = Role::all();
     foreach ($permissions as $permissionkey => $permission) {
         foreach ($roles as $roleKey => $role) {
             //If checkbox is clicked attach the permission
             if (!empty($arrayPermissionRoleMapping[$permissionkey][$roleKey])) {
                 // check that this permission has not already been attached to a role before attempting it again!
                 if (!$role->perms->find($permission->id)) {
                     $role->attachPermission($permission);
                 }
             } elseif (empty($arrayPermissionRoleMapping[$permissionkey][$roleKey])) {
                 $role->detachPermission($permission);
             }
         }
     }
     return redirect()->to('permission.index')->with('message', trans_choice('messages.record-successfully-saved', 1))->with('active_permission', $permission->id);
 }
开发者ID:echiteri,项目名称:iBLIS,代码行数:25,代码来源:PermissionController.php

示例14: getPermission

 public function getPermission($id)
 {
     return Permission::all();
 }
开发者ID:ashokadhikari92,项目名称:NCDB_Final,代码行数:4,代码来源:RolePermissionController.php

示例15: assignPermission

 /**
  * Gets all the current list of permission and returns to a view page.
  * @param $id
  * @return $this
  */
 public function assignPermission($id)
 {
     /*$permissions = $this->role->getPermissionsForGivenRole($id);*/
     $permissions = \DB::select('select permission_id from permission_role where role_id = ?', array($id));
     $permissions_array = array();
     foreach ($permissions as $key => $value) {
         $permissions_array[] = $value->permission_id;
     }
     //dd($permissions_array);
     $all_permissions = Permission::all();
     $role = $this->role->getRoleById($id);
     return view('userManagement.roles.permission')->with('all_permissions', $all_permissions)->with('role', $role)->with('permissions', $permissions_array);
 }
开发者ID:ashokadhikari92,项目名称:NCDB_Final,代码行数:18,代码来源:RoleController.php


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