Beispiel #1
0
 /**
  * Seed permissions.
  *
  * @param  array  $seeds
  */
 public function seed(array $seeds)
 {
     foreach ($seeds as $seed) {
         $group = PermissionsGroup::create($seed['group']);
         $permissions = array_map(function ($permission) {
             return new Permission($permission);
         }, $seed['permissions']);
         $group->permissions()->saveMany($permissions);
     }
 }
Beispiel #2
0
 /**
  * Map routes.
  *
  * @param  \Illuminate\Contracts\Routing\Registrar  $router
  */
 public function map(Registrar $router)
 {
     $this->bind('auth_permission', function ($hashedId) {
         return Permission::firstHashedOrFail($hashedId);
     });
     $this->bind('auth_permissions_group', function ($hashedId) {
         return PermissionsGroup::firstHashedOrFail($hashedId);
     });
     $this->group(['prefix' => 'permissions', 'as' => 'permissions.'], function () {
         $this->get('/', 'PermissionsController@index')->name('index');
         // auth::foundation.permissions.index
         $this->get('group/{auth_permissions_group}', 'PermissionsController@group')->name('group');
         // auth::foundation.permissions.group
         $this->group(['prefix' => '{auth_permission}'], function () {
             $this->get('/', 'PermissionsController@show')->name('show');
             // auth::foundation.permissions.show
             $this->delete('roles/{auth_role}/detach', 'PermissionsController@detachRole')->name('roles.detach');
             // auth::foundation.permissions.roles.detach
         });
     });
 }
 /**
  * Get the cached permission groups.
  *
  * @return \Illuminate\Database\Eloquent\Collection
  */
 private function getCachedPermissionGroups()
 {
     return $this->cacheResults('permissions-groups.filters', function () {
         return PermissionsGroup::has('permissions')->get();
     });
 }