> For the complete documentation index, see [llms.txt](https://l-shop-en.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://l-shop-en.gitbook.io/documentation/software-api/permissions/search-and-filter-data.md).

# Search and filter data

Using the `App\Services\Game\Permissions\Funnel` class object, you can filter the permissions of a user or group.

All collection objects below are of type A `Doctrine\Common\Collections\Collection`.

### Predicate

The predicate is the [DTO ](https://en.wikipedia.org/wiki/Data_transfer_object)class used to describe the rules for filtering data.

\
To filter permissions, you need an object of type `App\Services\Game\Permissions\Predicates\PermissionPredicate`.

### App\Services\Game\Permissions\Funnel::filterPlayerPermissions()

The method takes as parameters the object of the player whose permissions you want to filter and the `PermissionPredicate` object. Returns the collection of filtered permissions.

```php
$player = $storage->retrievePlayerByUsername('admin');
$funnel = new Funnel();
$predicate = (new PermissionPredicate())
    ->setPermission(new Regex('/^minecraft\..+$/ui'))
    ->setAnyServer(false)
    ->setServer('3');
$result = $funnel->filterPlayerPermissions($player, $predicate);
```

The above code filters user permissions in the `$result` variable using the following criteria:

* The name of the resolution begins with "minecraft."
* Permission refers to server "3".

### App\Services\Game\Permissions\Funnel::filterGroupPermissions()

The method takes as the parameters the group object whose permissions need to be filtered and the `PermissionPredicate` object. Returns the collection of filtered permissions.

```php
$group= $storage->retrieveGroup('players');
$funnel = new Funnel();
$predicate = (new PermissionPredicate())
    ->setPermission('groupmanager.manuadd')
    ->setAnyServer(true)
    ->setAnyWorld(false)
    ->setWorld('nether');
$result = $funnel->filterGroupPermissions($group, $predicate);
```

The above code filters the group permissions in the `$result` variable using the following criteria:

* The name of the resolution exactly matches "groupmanager.manuadd".
* Permission applies to any server.
* Resolution refers to the world of "nether".

### App\Services\Game\Permissions\Funnel::filterPermissions()

It filters the permission collection with the passed predicate.

```php
$collection = ...; // Original permission collection.
$funnel = new Funel();
$predicate = (new PermissionPredicate())
    ->setAnyContexts(false)
    ->setContexts('{}');
$result = $funnel->filterPermissions($collection, $predicate);
```
