Download the PHP package kalimeromk/filterable without Composer

On this page you can find all versions of the php package kalimeromk/filterable. 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 filterable

Filterable - Laravel Package for Dynamic Filtering

Filterable is a Laravel package designed to simplify dynamic filtering and searching across models and their relationships, eliminating the need for repetitive query code. It provides an easy-to-use trait and a query macro for building powerful, dynamic query filters.


Requirements

Installation

Require the package via Composer:

The package uses package auto-discovery, so no manual registration is needed. If auto-discovery is disabled, register the service provider yourself:


Usage

1. The whereLike macro

whereLike performs a LIKE search over several columns at once, including columns on related models. All conditions are grouped and combined with OR, so it can be chained with other constraints safely.

Searching related models

Use dot notation. Everything before the last dot is treated as the relation, so nested relations work too:

A single attribute may be passed as a plain string: ->whereLike('email', 'john@').


2. The Filterable trait

The trait adds a filter() scope that turns a request payload into query constraints.

How each filter key is resolved

Filter key Condition applied Requirement
is_active where('users.is_active', (bool) $value) listed in $boolFields
name where('users.name', 'LIKE', '%value%') in $fillable and $likeFields
email exact match in $fillable
['a', 'b'] whereIn in $fillable
age_min where('users.age', '>=', $value) age in $fillable
age_max where('users.age', '<=', $value) age in $fillable

Keys that don't resolve to a fillable column are ignored, which keeps arbitrary request input from reaching the query. null values are skipped, so absent query parameters don't narrow the result set.

[!IMPORTANT] For age_min / age_max it is the base column (age) that must be in $fillable — not age_min itself.

$likeFields applies to this model's own columns. To search related models, use the whereLike macro.

Example controller

Request:

Returns active users whose name contains "Jane" and whose age is between 25 and 35.


Testing

The package is tested with Orchestra Testbench:

License

This package is open-sourced software licensed under the MIT license.


All versions of filterable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^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 kalimeromk/filterable contains the following files

Loading the files please wait ...