Download the PHP package meius/laravel-filter without Composer

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

Laravel Filter Package

Build Status codecov PHP Version Laravel Version

Table of Contents

Overview

The meius/laravel-filter package provides a convenient way to apply filters to Eloquent models in a Laravel application. It allows you to define filters using attributes and apply them dynamically based on the request.

Requirements

Getting Started

To get started with the meius/laravel-filter package, follow the installation instructions below and check out the usage examples.

Installation

  1. Install the package via Composer:

Configuration

  1. To publish the configuration file, run the following command:

This will create a config/filter.php file where you can customize the filter settings.

Usage

Creating Filters

  1. To create a new filter, use the make:filter Artisan command:

Applying Filters

  1. Define filters using attributes in your controller methods:

  2. To apply filters to related models, use the ApplyFiltersTo attribute with multiple model classes:

Applying Filters to Route Groups

By default, filters are applied to the web and API route groups. To customize this behavior, you must publish the configuration file and make the necessary adjustments.

  1. Publish the Configuration File:

  2. Update the Configuration: Open the config/filter.php file and modify the route_groups section to specify which groups should have filters applied.

Caching Filters

  1. To cache the filters for faster loading, run the following Artisan command:

Example

Here is an example of how to define and apply filters:

  1. Create a filter:

  2. Create a filter for related models:

  3. If you need to apply a filter according to a condition, you can use the canContinue method:

Using ExcludeFrom and OnlyFor Attributes

You can use the ExcludeFrom and OnlyFor attributes to conditionally apply filters.

  1. Create a filter with ExcludeFrom:

  2. Create a filter with OnlyFor:

  3. You can also use the ExcludeFrom and OnlyFor attributes together(If you need it \@_@/):

  4. Create a filter using properties:

  5. Create a filter using methods:

Prioritization of Settings

When defining filter settings, the priority of the settings is as follows:

  1. Method: The highest priority. If a method is defined to specify the filter settings, it will override any settings defined via properties or attributes.
  2. Property: Medium priority. If a property is defined to specify the filter settings, it will override any settings defined via attributes but will be overridden by method definitions.
  3. Attribute: The lowest priority. If settings are defined via attributes, they will be used only if there are no corresponding settings defined via methods or properties.

This means that if there are conflicting settings defined in multiple ways, only the setting with the highest priority will be applied. For example, if a filter has both a method and an attribute defining the same setting, the method's setting will take precedence and be applied, while the attribute's setting will be ignored.

Example Request Structure

  1. For filters to work correctly, the query must have the appropriate structure. Here is an example of how the query should be structured:

  2. Example request:

Configuring Filter Aliases and Prefixes

Adding Filter Aliases to Models

  1. To add filter aliases to your models, use the HasFilterAlias trait and define the $filterAlias property in your model.

Configuring the Filter Prefix

  1. You can change the filter prefix by modifying the config/filter.php configuration file. Update the prefix value to your desired string.

Example JSON and URL Requests

  1. JSON Request

    Here, "f" is the filter prefix specified in the config, and "h5p" is the alias defined in the model.

  2. URL Request

    Similarly, in the URL request, "f" represents the filter prefix and "h5p" is the alias.

Advanced Usage

Complex Filters

  1. Create a complex filter that combines multiple conditions:

Combined Filters

  1. Apply multiple filters to a single query:

Examples for Other Databases

Using the query method, you can create filters for different databases.

PostgreSQL

  1. Create a filter for a PostgreSQL database:

SQLite

  1. Create a filter for an SQLite database:

Support

For support, please open an issue on the GitHub repository.

Contributing

We welcome contributions to the meius/laravel-filter library. To contribute, follow these steps:

  1. Fork the Repository: Fork the repository on GitHub and clone it to your local machine.
  2. Create a Branch: Create a new branch for your feature or bugfix.
  3. Write Tests: Write tests to cover your changes.
  4. Run Tests: Ensure all tests pass by running phpunit.
  5. Submit a Pull Request: Submit a pull request with a clear description of your changes.

For more details, refer to the CONTRIBUTING.md file.

License

This package is open-sourced software licensed under the MIT license.


All versions of laravel-filter with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/console Version ^9.0 || ^10.0 || ^11.0 || ^12.0
illuminate/database Version ^9.0 || ^10.0 || ^11.0 || ^12.0
illuminate/filesystem Version ^9.0 || ^10.0 || ^11.0 || ^12.0
illuminate/http Version ^9.0 || ^10.0 || ^11.0 || ^v12.0
illuminate/routing Version ^9.0 || ^10.0 || ^11.0 || ^12.0
illuminate/support Version ^9.0 || ^10.0 || ^11.0 || ^12.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 meius/laravel-filter contains the following files

Loading the files please wait ....