Download the PHP package touhidurabir/laravel-filterable without Composer

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

A package to filter laravel model based on query params or retrived model collection.

Installation

Require/Install the package using composer:

To publish the config file:

Configuration

The package comes with a configuration file named filterable that has to 2 important configs

Base Filter Class

This is a array that contains the base filter class for both the Query and Collection filter as :

If one need to even extend it to add more functionality or any custom feaure, can do it and set the base class in the config file .

Filter Class Namespace

This config define what would be the default namespace(and the store path) of the generated filter classes for the both the Query and Collection filter classes as :

If needed to, one can change the default path from there . but it is also possible to pass a different namespace to the filter generate command to provide a different namespace.

Command

This package includes a handly command to generate filter classes as

It will generate 2 class UserQueryFilter and UserCollectionFilter as per defined namespace in the config file .

This command also includes several handful options to make the filer class generation as flexiable as possible such as

--filters=

By passign comma separated filters, it will put those filters as filterable method in both the query and collection filter class as :

For Query FIlter :

For Collection Filter :

--query-suffix=QueryFilter

Define what would be query filter class file name and class name suffix .

--collection-suffix=CollectionFilter

Define what would be collection filter class file name and class name suffix .

--no-suffix

If passed as switch option or flag, no suffix will be added to query or collection filter class names or files name.

--only-query

If passed as switch option or flag, will only generate the query filters and omit the collection filter class.

--only-collection

If passed as switch option or flag, will only generate the collection filters and omit the query filter class.

--replace

If passed as switch option or flag, will replace the existing file. By defalt if a given file already present, it will not replace it .

Usage

Generate the filters as

it will generate UserQueryFilter.php and UserCollectionFilter.php class at the given path as :

and the use the Filterable trait in the model as

The form some controller, use it as such

Also possible to use an existing array to pass as query to initiate the filter class as

Note that it's not required to pass the $request as if not passed , it will resolve it from the Request Facade . Useful for case like when app running on laravel octane.

It can also handle the filter param validation as :

Set the validation rules there and those params that do not pass the validation will not be applied.

WHY a Collection Filter ?

It is a valid question why a collection filter as most of the time a query filter is sufficient. But some times a collection filter can be helpful to do some custom filter again after records are pull from DB. As this package allow to generate seperate collection filter, in those cases it can be helpful to such cause .

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT


All versions of laravel-filterable with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4.0
touhidurabir/laravel-stub-generator Version ^1.0
illuminate/support Version ^8.60
illuminate/console Version ^8.60
illuminate/http Version ^8.60
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 touhidurabir/laravel-filterable contains the following files

Loading the files please wait ....