Skip to content

Commit

Permalink
Update docs for allowing empty input
Browse files Browse the repository at this point in the history
  • Loading branch information
Tucker-Eric authored May 7, 2024
1 parent 4790962 commit 38c1dee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,11 @@ This would create `app/ModelFilters/AdminFilters/UserFilter.php`
### Defining The Filter Logic
Define the filter logic based on the camel cased input key passed to the `filter()` method.

- Empty strings and null values are ignored
- Empty strings and null values are ignored by default.
- Empty strings and values can be configured not to be ignored by setting `protected $allowedEmptyFilters = false;` on a filter.
- If a `setup()` method is defined it will be called once before any filter methods regardless of input
- `_id` is dropped from the end of the input key to define the method so filtering `user_id` would use the `user()` method
- (can be changed with by definining `protected $drop_id = false;` on a filter)
- Can be changed with by definining `protected $drop_id = false;` on a filter
- Input without a corresponding filter method are ignored
- The value of the key is injected into the method
- All values are accessible through the `$this->input()` method or a single value by key `$this->input($key)`
Expand Down Expand Up @@ -692,7 +693,7 @@ OR:
}
```

In your view `$users->render()` will return pagination links as it normally would but with the original query string with empty input ignored.
In your view `$users->render()` will return pagination links as it normally would but with the original query string with empty input ignored if `protected $allowedEmptyFilters` is not set to `false` on the filter.


# Contributing
Expand Down
2 changes: 1 addition & 1 deletion src/ModelFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ abstract class ModelFilter
/**
* Filter out empty input so filter methods won't be called with empty values (strings, arrays, null).
*
* @var array
* @var bool
*/
protected $allowedEmptyFilters = false;

Expand Down

0 comments on commit 38c1dee

Please sign in to comment.