Skip to content

Blacklist

Eric Tucker edited this page Jul 12, 2018 · 2 revisions

All methods are whitelisted by default and 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 below example secretMethod() is dynamically whitelisted in the setup() method if Auth::user()->isAdmin() returns truthy. After whitelisting secretMethod will be called if the input array contains a secret_method key.

Example:

protected $blacklist = ['secretMethod'];

public function setup()
{
    if(Auth::user()->isAdmin()) {
        $this->whitelistMethod('secretMethod');
    }
}

public function secretMethod($val)
{
    return $this->where('some_column', $val);
}
Clone this wiki locally