diff options
| author | Sam Light <samlight1994@gmail.com> | 2025-03-28 01:09:18 +0000 | 
|---|---|---|
| committer | Sam Light <samlight1994@gmail.com> | 2025-03-28 01:09:18 +0000 | 
| commit | 4605d101a402e715e35a4ea61cf175bba1ba4f6f (patch) | |
| tree | 0fd04fe5e342caa4bd53b5ef06e2c211dc2285ab | |
| parent | 9c26700fff79a882cb3b662a032d4752341271d8 (diff) | |
Setup some common filter features
| -rw-r--r-- | src/Toolbar/Filter.php | 14 | 
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Toolbar/Filter.php b/src/Toolbar/Filter.php index ebda2c6..19f29cc 100644 --- a/src/Toolbar/Filter.php +++ b/src/Toolbar/Filter.php @@ -2,7 +2,21 @@  namespace Lightscale\LaralightTables\Toolbar; +use Closure; +  abstract class Filter extends Item  { +    protected ?Closure $filterCallback = null; + +    public function filter(callable $filterCB): static +    { +        $this->filterCallback = $filterCB; +        return $this; +    } + +    public function applyFilter(Builder $query): void +    { +        ($this->filterCallback)($query, $value); +    }  }  | 
