Download the PHP package laraditz/model-filter without Composer

On this page you can find all versions of the php package laraditz/model-filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package model-filter

Laravel Model Filter

Latest Stable Version Total Downloads License

A flexible Eloquent model filter for Laravel with operator support, OR grouping, and relationship filtering.

v2 breaking change: Filter params are now namespaced under filters[]. See the breaking changes section below.

Requirements

Installation

Setup

Add the Filterable trait to your model and declare a $filterable allowlist:

Optionally scaffold a filter class with the Artisan command:

This creates app/Filters/UserFilter.php. Use --force to overwrite an existing file.

Then add your custom methods:

Fields without a custom method are handled automatically.

Custom method precedence: When a custom method exists for a field, it always takes precedence over auto-handling — and it receives only the value, not the operator. This means ?filters[age][gte]=18 will call age('18') and silently drop the gte operator. If you need operator-based filtering for a field, do not define a custom method for it and let auto-handling do the work.

Usage

Pass $request->all() to filter():

Query param format

Supported operators

Operator SQL equivalent Notes
eq = ? Default when no operator bracket used
neq != ?
like LIKE ? Value wrapped in %…% automatically
gt > ?
gte >= ?
lt < ?
lte <= ?
in IN (?) Comma-separated string → array
between BETWEEN ? AND ? Comma-separated, exactly 2 values

Relationship filtering

Add the relationship column in dot-notation to $filterable:

The package translates role.name into a whereHas('role', ...) clause automatically. All operators work:

Only one level of nesting is supported (relation.column). Deeper nesting (e.g. post.comments.body) is not supported.

Custom relationship query

If you need more control — for example filtering on a condition that spans multiple columns of the related model — define a custom method in your filter class:

Remember to add the key to $filterable:

Security

Only fields listed in $filterable can be filtered. Unlisted fields are silently ignored. Values are bound via PDO prepared statements - no SQL injection risk.

Breaking Changes from v1

Area v1 v2
Query params ?name=farhan ?filters[name]=farhan
Laravel support 7–12 9–13
PHP minimum 7.4 8.1
Lumen Supported Dropped
$filterable empty All params passed through All filtering disabled
Filter::__call__ Auto-proxied to Builder Removed — use $this->query directly
Filter::sort() On Filter base class Moved to Filterable trait

Credits

License

MIT. Please see the license file for more information.


All versions of model-filter with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^9.0|^10.0|^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package laraditz/model-filter contains the following files

Loading the files please wait ...