Query Scopes
Definition
A Query Scope is a sort of complex condition you can add easily to an Eloquent Query.
For more information about Query Scopes, please refer to the Laravel official documentation.
By default, Uccello provides 3 query scopes:
inDomain
filterBy
assignedUser
Default Query Scopes
inDomain
This local scope allows to easily filter the records of a module, to visualize only those of the current domain or its child domains if the descending view is activated.
This scope is activated only if the module contains a domain_id
column in this related database table.
The following example will retrieve all people related to the domain with the slug uccello
:
You can use this scope with other conditions:
filterBy
This local scope allows to filter records of a module. You can pass a filter's id
, a filter object
or an array
containing the description of the filter you want to apply.
If you use an existing filter, only the conditions
and the sort order
will be applied. The columns
definition will be ignored.
You can use this scope with other conditions:
assignedUser
This global scope is automatically applied by default to all queries of all private modules and allows to retrieve records only if there are assigned to the authenticated user of to a group to which he belongs. It is applied only if a column assigned_user_id
exists in the database table related of the module. For more information see AssignedUser Uitype documentation.
This global scope is initialized in the UccelloModule trait. As explained in the Laravel official documentation, if you would like to remove it for a given query, use the withoutGlobalScope
method:
People::withoutGlobalScope(\Uccello\Core\Support\Scopes\AssignedUser::class)
Last updated