Download the PHP package kouks/laravel-filters without Composer

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

Laravel Filters

Scrutinizer Code Quality Latest Version on Packagist Build Status StyleCI

Contents

Installation

Composer

Open your console and cd into your Laravel project. Run:

And you are all set up!

Usage

Creating filters

You can store your filters anywhere in your project but I advise to use the app/Filters directory to keep thing constistent. In your filters directory, create a new filter class as in following example. Not that we suppose that we have a Post model with the id, title, body and active columns including timestamps.

Now you can specify your orderable and searchable columns.

Note that all the filters take data from the query strings in you url. The above example will react to query strings in format e. g. /?title=asc or /?search=pattern.

Also note that oderable array is a key - value pair. This is because the key corresponds to the query string name, whereas the value corresponds to a database column.

Setting up the filters

Simple searching

Your class for simple searching could look as follows.

This setup reacts to the url query string in format /?search=pattern and will return all the results that match the search pattern in specified columns.

Simple ordering

Simple ordering class could look like this.

This setup allows you to use the query strings in format /?id={desc/asc} or /?topic={desc/asc}. Note that we specified that the topic query string points to the title database column.

Searching in related tables

Your class for related searching could look as follows. For this example we suppose to have the Author model with the columns of id and name, which has a one - many relationship with the Post model.

This format allows us to include the author's name and id in the results. Simple as that, however, note that this will work only for one - many and one - one relationships, which are properly set up, following the Laravel conventions.

Orderng by related table's columns

Related ordering is set up as in the folowing example. For this example we suppose to have the Author model with the columns of id and name, which has a one - many relationship with the Post model.

This format allows us to order also by the author's name and id with the query string of /?{author_id/author_name}={desc/asc}. Simple as that, however, note that this will work only for many - one and one - one relationships, which are properly set up, following the Laravel conventions.

Custom filters

You are also allowed to setup you own filters by creating new methods on the filter class itself. Consider following example:

Above example will correspond to the query string in the format /?popular={desc/asc}. The query string name corresponds to the name of the method and its value is passed as an argument. Note that you are able to access the parent class builder property and adjust it accordingly.

Abstracion

This package comes with the Koch\Filters\Contracts\Filter interface, which allows you to make your own implementations of the filter.

FAQ

Nobody has ever asked me anything about this package so I can't determine the frequency of questions.


All versions of laravel-filters with dependencies

PHP Build Version
Package Version
Requires illuminate/database Version ^5.3
illuminate/http Version ^5.3
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 kouks/laravel-filters contains the following files

Loading the files please wait ....