Download the PHP package amirhshokri/laravel-filterable without Composer

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

Laravel filterable

Introduction

Laravel Filterable helps you add efficient filtering logic to the Laravel query builder. You can use the default filter logic, define custom filter logic manually, or create it using the provided command with any suffix in any path you choose. By enabling auto-discovery mode, the package will automatically locate the desired filter class for you.

Installation

You can install the package via composer:

You can publish the config file with:

This is the contents of the published config file:

Basic usage

1 - Add the Filterable trait to your model.

2 - Add the filter() method to your query builder.

3 - All set! Make a request:

How to use filter() method?

Method 1: Using default filter

If you don’t provide a custom filter class for the filter() method and auto-discovery is turned off in the config file, the package will use the default filter functionality for your model, as explained previously in the Basic usage section.

Method 2: Passing a custom filter class

You can pass a custom filter class to the filter() method to enforce specific filtering logic for your model:

Once you have created a custom filter class, you can extend the filtering logic for each field you wish to filter. Add a function in the custom filter class that corresponds to the name field in your request body:

Method 3: Using auto-discovery

When auto-discovery is enabled, this package will search for a filter class named {ModelName}{Suffix}.php using the namespace and suffix parameters defined in the config file. If the custom filter class is not found in the expected location, an exception will be thrown.

Method 4: Nested filters

In more complex scenarios, you can nest another filter() within your current filter logic to apply multiple conditions, such as filtering users based on their post titles. Make sure the Filterable trait is added to all relevant models:

Additional Notes

1 - You can optionally specify which fields are allowed for filtering using the $allowedFilterParameters array. Leave it empty or omit it entirely to allow filtering on all fields:

2 - Use the operatorMapper() method to map operators to their database equivalents:

Supported Operator Mapped Version
isEqualTo =
isNotEqualTo !=
greaterThan >
lessThan <
greaterThanOrEqualTo >=
lessThanOrEqualTo <=
between
in
contains

For example:

3 - OperatorEnum can be used as needed:

Credits

License

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


All versions of laravel-filterable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/database Version ^10.0
illuminate/support Version ^10.0
illuminate/console Version ^10.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 amirhshokri/laravel-filterable contains the following files

Loading the files please wait ....