Download the PHP package usermp/laravel-filter without Composer

On this page you can find all versions of the php package usermp/laravel-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 laravel-filter

Laravel Filterable

usermp-laravel-filterable

Overview

The Filterable trait is designed to be used within Eloquent models in a Laravel application. It provides a convenient way to apply filters to Eloquent queries based on HTTP request parameters. This trait supports filtering by model attributes as well as by attributes of related models, using various operators.

Installation

  1. Add the package to your project using Composer:

  2. Add the Filterable trait to your Eloquent model:

Usage

To use the Filterable trait, call the filter scope on your model query and pass the Illuminate\Http\Request object. Filters should be passed in the query string under a main key, which defaults to filter.

Example in a Controller:

Examples

All filter parameters should be nested under a main key in the query string. The default key is filter.

1. Basic Attribute Filtering

Assume the Post model has title and status in its $filterable array.

2. Filtering by Related Model Attributes

Assume the Post model has user in $filterableRelations and the User model has a name attribute.

3. Using Specific Operators

4. Customizing the Main Filter Key

If you defined $filterRequestKeyOverride = 'my_query_filters'; in your model:

GET /posts?my_query_filters[title]=My%20Post

Supported Operators

The following operators can be used by specifying them as a key for the filter value:

Operator Query String Example Description
(none) filter[title]=word Default: LIKE '%word%' for string values.
equal filter[status][equal]=active Exact match (=).
notequal filter[status][notequal]=archived Not equal (!=).
gt filter[views][gt]=100 Greater than (>).
gte filter[views][gte]=100 Greater than or equal to (>=).
lt filter[stock][lt]=10 Less than (<).
lte filter[stock][lte]=10 Less than or equal to (<=).
like filter[description][like]=important LIKE '%important%'.
notlike filter[description][notlike]=trivial NOT LIKE '%trivial%'.
startswith filter[sku][startswith]=ABC LIKE 'ABC%'.
endswith filter[filename][endswith]=.pdf LIKE '%.pdf'.
in filter[id][in]=1,2,3
filter[id][in][]=1&filter[id][in][]=2
Matches any of the comma-separated values.
notin filter[category][notin]=old,deprecated Does not match any of the comma-separated values.
between filter[date][between][]=2023-01-01&filter[date][between][]=2023-01-31 Value is between two specified values.
notbetween filter[price][notbetween][]=100&filter[price][notbetween][]=200 Value is not between two specified values.
null filter[deleted_at][null] Value is NULL.
notnull filter[confirmed_at][notnull] Value is NOT NULL.

Note on in, notin, between, notbetween: For between and notbetween, the values must be provided as an array in the query string as shown. For in and notin, values can be a comma-separated string or an array.

License

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


All versions of laravel-filter with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0|^8.1|^8.2|^8.3
illuminate/support Version *
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 usermp/laravel-filter contains the following files

Loading the files please wait ...