Download the PHP package albetnov/laravel-filterable without Composer

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

Query String based filter for Laravel

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A Laravel Model Filterable to automatically filter a model based on given query string

Installation

You can install the package via composer:

Usage

Simply add Filterable trait in your model and define either $filterableColumns or filterableColumns() (if you need extra logic) to define a filterable columns:

Getting Filterable Columns

If both are defined, Filterable will priority the method over property. As defined in: Filterable.php

If none exist though, Filterable will throws PropertyNotExist exception.

Filterable Type

There are Five FilterableType options available:

Modifiers

Each of the FilterableType supports a modifier to alter the behaviour of filtering from the assigned field. There are 2 modifiers you can use for now.

The modifiers can be chained together: FilterableType::DATE->related()->limit() to combine conditions

Custom Type

Custom Type does not support modifier.

As mentioned before there are 5 types exist for Filterable, the last one is custom which are treated differently. Custom Type is part of static method of FilterableType and therefore requires you to define it in filterableColumns() method.

The custom method accept one argument, $allowedOperators that are an array of Operators. This argument used to define the whitelist of allowed operators for your custom filter.

The custom type requires a handler, both of the handler and the field have to be defined under this convention:

Notice that the columns are defined in snake case while the method is camel case. Your function should also have three arguments defined. First is the Builder, a raw operator, and finally a raw value. The raw term means that these value are not formatted and they are passed quickly from the query string. However, they are validated.

Using in model

Just call filter scope and you're set:

Request Schema

Here is the expected request payload schema that can be read by Laravel Filterable:

All the filters must be placed within filters key and the values should be an array of object containing:

The above schema when mapped to query string will be like this:
?filters[0][field]=customer_name&filters[0][operator]=eq&filters[0][value]=asep

Supported Operators

Limitations

The value is limited exclusively to the string type, and each casting is performed through types defined in filterableColumns. Ambiguous casting may occur forarrays with items containing , as the value delimiter. Please avoid using , in your values, as they are used as the internal array delimiter. Another case could involve numbers with more than one . delimiter.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

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/contracts Version ^10.44|11.*
laravel/framework Version ^10.44|11.*
nesbot/carbon Version ^2.67|3.*
orchestra/testbench Version 8.*|9.*
spatie/laravel-package-tools Version ^1.16.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 albetnov/laravel-filterable contains the following files

Loading the files please wait ....