Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/filters-and-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ $this->callback('search', [
- Use **nested arrays** when fields are semantically related (e.g., date range with start/end, tag search with options)
- Use **`extraParams` config** when fields are independent but happen to be used together in one callback

Another use case for `extraParams` is, when you need to inject additional values without going through the URL, e.g. the
logged-in user data (e.g. `'extraParams' => ['user_id']`):
```php
$identity = $this->request->getAttribute('identity');
if ($identity) {
$queryParams = $this->request->getQueryParams();
$queryParams['user_id'] = $identity->get('id');
}
$query = $this->Articles->find('search', search: $queryParams);
```
The callback then is active on both the primary query string and the passed user id.

----------

## Options
Expand Down