From c1c10a14fe0632a598c6d65de6197ff02d87ab7e Mon Sep 17 00:00:00 2001 From: Eric Tucker Date: Thu, 10 May 2018 21:39:14 -0700 Subject: [PATCH] update readme --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index ad838e1..12049b9 100644 --- a/README.md +++ b/README.md @@ -268,6 +268,8 @@ use EloquentFilter\ModelFilter; class UserFilter extends ModelFilter { + protected $blacklist = ['secretMethod']; + // This will filter 'company_id' OR 'company' public function company($id) { @@ -300,6 +302,11 @@ class UserFilter extends ModelFilter $this->withTrashed(); } } + + public function secretMethod($secretParameter) + { + return $this->where('some_column', true); + } } ``` @@ -307,6 +314,24 @@ class UserFilter extends ModelFilter > **Note:** In the example above all methods inside `setup()` will be called every time `filter()` is called on the model +#### Blacklist + +Any methods defined in the `blackist` array will not be called by the filter. Those methods are normally used for internal filter logic. + +The `blacklistMethod()` and `whitelistMethod()` methods can be used to dynamically blacklist and whitelist methods. + +In the example above `secretMethod()` will not be called, even if there is a `secret_method` key in the input array. In order to call this method it would need to be whitelisted dynamically: + +Example: +```php +public function setup() +{ + if(Auth::user()->isAdmin()) { + $this->whitelistMethod('secretMethod'); + } +} +``` + #### Additional Filter Methods