PHPackages                             mostafijartisan/wherefilter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. mostafijartisan/wherefilter

ActiveLibrary

mostafijartisan/wherefilter
===========================

The package allows developers to dynamically apply `where` and `whereLike` filters to Eloquent queries without writing repetitive query-building logic in their controllers.

v0.1.1(1y ago)18MITPHPPHP ^8.0

Since Nov 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mostafijartisan/whereFilter)[ Packagist](https://packagist.org/packages/mostafijartisan/wherefilter)[ RSS](/packages/mostafijartisan-wherefilter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

Core idea of whereFilter Laravel package
========================================

[](#core-idea-of-wherefilter-laravel-package)

The package allows developers to dynamically apply `where` and `whereLike` filters to Eloquent queries without writing repetitive query-building logic in their controllers.

Instead of explicitly writing `->where()` or `->whereLike()` statements for each field, you define an array of filters in the model, and the package automatically applies those filters based on the request data.

---

Installation
------------

[](#installation)

```
composer require mostafijartisan/wherefilter
```

How it works
------------

[](#how-it-works)

1. **Model class config**:

- You have to import Filterable trait in your desire model class.
- Then you have to create a `$whereFilters` property that defines which fields can be filtered and how (e.g., `where`, `whereLike`).
- Code Example:

    ```
