Download the PHP package aerynl/refinement without Composer

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

Refinement package

Short description

Easy refinements for use with Laravel. Contains functions for saving filters in Session, generating filter options and fetching filter results.

Quick start

Second command will create \app\config\packages\aerynl\refinement\config.php file, where you can specify table connections and filter names.

How to use

If you want to save filters in session, run:

If you want to get filtered results, run:

If you want to get refinement options, run:

What to write in config file

In config file you can specify table connections in joins array and filter names in titles array.

Table connections

Sometimes we need to make joins to create the necessary queries.

Because it's hard to create proper queries from the inputted parameters the configuration below will be used to create the joins. Be sure all the tables you are using for filtering have join configuration! Note, this doesn't mean you should specify in join array tables, which are used to get options. For example, if you filter products by product.color_id and you have table colors, where all colors are kept, there is no need to add colors table to joins array. But if you always need to show only that products, which have product_sale.active = false, be sure that product_sale table is specified in config file.

Joins array has the following scheme:

Titles of filters

Configure the name of your refinements here. If no name is entered the standard naming format will be used (ucfirst)

Example:

Refinement title translations

Create a file called refinements.php in /app/lang/en, there you'll be able to add translations for the titles you've added to the configuration.

Detailed information about functions

Refinement::updateRefinements($session_name, $new_refinements)

This method is used to save filters in session. $session_name is the name of session, so you can use several filters sessions in one application. $new_refinements is a new filters array, that should be remembered. Keep the following scheme to have package work correctly:

Refinement::getRefinedQuery($main_model, [$session_name, $eager, $additional_wheres, $additional_joins, $refinements_array])

This method is used to generate query for getting filtered results. Why doesn't it return filtered results? Sometimes you will need to do some operations with query before getting the results, for example groupBy, orderBy, paginate and others. So you can use this function in the following way:

Passed variables:

Refinement::generateOptionsArray($main_model, [$options_scheme, $session_name, $eager, $additional_wheres, $additional_joins])

This method is used for generating array of refinements options using passed scheme. It returns array of options with the following scheme:

$column_name, $parent_table and $option_id are used for creating $new_refinements array for updateRefinements function. For example you can show options like checkboxes with name="$parent_table[$column_name][]" and value="$option_id".

Passed variables: Note, first 5 variables should be the same as for getRefinedQuery function if you want to have actual $number_of_results.

e.g.

This means, that results are filtered by products.color_id. And color names you can see in colors.color_name column.

What will be done soon


All versions of refinement with dependencies

PHP Build Version
Package Version
No informations.
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 aerynl/refinement contains the following files

Loading the files please wait ....