Advanced Collection Configuration
Estimated reading: 1 minute
In Deepser you can define, through custom code, filters on the collection of data shown in the grid.
This feature is useful when you want to define advanced conditions that cannot be expressed by query builder.
To define custom conditions on the collection, from the grid configuration menu click on the icon </> to view the scripting area.
Inside it you can insert the PHP code to handle on the data collection through the related query.
EXAMPLE
In this example you want to configure a custom filter on the Collection of service operations recovered from the database.
Through this filter only the service operations assigned to the groups of which the user is a member will be retrieved.
// Deep::helper('deep_admin')->getCurrentUser() returns the current user object instance
// getGroupIds() returns entity_ids of of the groups of which the current user is a member
$currentUserGroups = Deep::helper('deep_admin')->getCurrentUser()->getGroupIds();
// modify the where clause of the query by adding our condition
$this->getCollection()->getSelect()->where("main_table.assigned_group_id IN (" . implode($currentUserGroups,',')