Download the PHP package altrntv/eloquent-filter without Composer

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

Eloquent Filter

Packagist Version GitHub Actions Workflow Status Packagist Downloads

Eloquent Filter provides a clean and expressive way to apply dynamic, request-driven filters to your Eloquent models. It automatically maps incoming request parameters to filter methods, making complex query filtering simple and maintainable.

Table of Contents

Requirements

This package requires:

Installation

Install the package via Composer:

Basic Usage Filters

Extend your model with the Filterable trait:

After adding the trait, your model gains two new query builder methods:


Creating a Filter Class

You can create a filter class using the Artisan command:

Then, define methods corresponding to each filterable parameter. Each method should accept a value and modify the query builder accordingly.


Controller Example


Validating Filters

It’s recommended to validate incoming filter parameters in your request class:


Casting Filter Values

Eloquent Filter supports the following cast types: integer, string, boolean, and array.

To cast a value, define it in the $casts property of your filter:

And in your form request:

A typical request might look like this:


Joining Parameters

Sometimes multiple request parameters represent a single logical concept. For example, vip_at_from and vip_at_to form a date range.

Eloquent Filter allows you to group multiple parameters under a single key using the $joinParameters property.

All keys inside the group are:

Example Filter Class

Request Example

Transformed Parameters

This approach is especially useful for handling ranges or multipart filters, keeping your request parameters clean and your filter methods readable.

Basic Usage Sorts

Eloquent Filter now supports sorting via the Sortable trait and EloquentSort classes. This allows you to apply dynamic sorting based on HTTP requests or string parameters.

Extend your model with the Sortable trait:

After adding the trait, your model gains two query builder methods:


Creating a Sort Class

You can create a sort class using the Artisan command:


Request Example

The sort string is split by the configured separator (, by default), and the direction is inferred from the - prefix.


Applying Sort

In controller:

Or using a manual string:

Testing

Contributing

Contributions are welcome! If you’d like to improve this package, please fork the repository and open a pull request. Bug fixes, new features, and documentation improvements are all appreciated.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of eloquent-filter with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/console Version ^11.0|^12.0|^13.0
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/support Version ^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 altrntv/eloquent-filter contains the following files

Loading the files please wait ...