Download the PHP package kirschbaum-development/livewire-filters without Composer

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

Latest Version on Packagist Total Downloads Actions Status

Livewire Filters is a series of Livewire components that provide you with the tools to do live filtering of your data from your own Livewire components.

Requirements

This package requires Laravel 9.0+ and Livewire 2.10+.

Installation

To get started, require the package via Composer:

Publishing views

The included filters are made with Tailwind CSS and the Tailwind CSS Forms plugin. We recommend publishing the views and changing the markup to match whatever styling or CSS framework your project uses.

Publishing config

Publishing the config file is only necessary to enable query string usage.

Usage

Define your filters

You can use filters in your Livewire component by including the HasFilters trait provided by the package.

With the trait included, define a filters method that returns an array of Filter objects you want to use in your component. The included Filter class has a series of fluent methods for building up the specifics of each of your filters.

Use your filters

With your component setup, you can include filters in the view file of your Livewire component. In order to setup the filter, simply use one of the filter components and pass the specific filter by its key. The component will take care of setting itself up.

There is more information below about the included filters in the package.

Determining filtered status/count

The HasFilters trait includes two computed properties you can use to determine if there are active filters and how many of your filters are currently active. You can access these directly in your Livewire component by using $this->isFiltered or $this->activeFilterCount. You can also pass one or both of these properties to your Livewire component through the render method if you so choose.

These computed properties are handy if you want to change the color of a button, show/hide a specific section of your UI, show a badge of active filters, or simply show a visual indicator that there are active filters being applied.

Getting filtered values

Because the $filters array contains Filter objects, you will need to either access the value property, use the value() method, or use the included getFilterValue($key) helper method.

Example parent component

Included filters

The package includes 4 basic filters that can be used in your Livewire components.

Checkbox filter

The checkbox filter allows you to select any number of options. Every time a change is made, the filter will emit an event with an array of the currently checked values.

Setting Type Example
key string 'type'
options array ['a', 'b', 'c']
default array ['a', 'b']
value array ['b', 'c']

Radio button filter

The radio button filter allows you to select a single option from the list of options. Every time a change is made, the filter will emit an event with the currently checked value.

Setting Type Example
key string 'type'
options array ['a', 'b', 'c']
default string 'a'
value string 'b'

Select menu filter

Similar to the radio button filter, the select menu filter allows you to select a single option from the list of options from a select menu. Every time a change is made, the filter will emit an event with the currently selected value.

Setting Type Example
key string 'type'
options array ['a', 'b', 'c']
default string 'a'
value string 'b'

Text box filter

The text box filter allows you to type freeform text that you can use for filtering. Every time a change is made, the filter will emit an event with the value of the text field.

Setting Type Example
key string 'name'
default string 'John'
value string 'Jane'

The Filter class

The Filter class provides a fluent interface for defining filters in your Livewire component as well as retrieving information about the filter.

make($key)

The first method you must call is the make method and pass it a unique key. After this method has been called, you can call any of the other methods in whatever order you want.

options($values)

If you're using a filter that requires options, you can pass an array of those values into the options method. Calling the options method without any arguments will return the defined options for the filter.

value($values)

If you would like to set the value of a filter, you can pass the value or an array of values into the value method. Calling the value method without any arguments will return the current value of the filter.

default($values)

When defining a filter, you should use the default method to set the initial value of the filter. This will store the initial value on the object as well to help with determining the status of active filters as well as resetting the filter to its original state. Calling the default method without any arguments will return the initial value that you specified when you defined the filter.

meta(array $values)

If you would like to set additional information on the filter to be used in the view file, you can pass an array of values into the meta method. Calling the meta method without any arguments will return the current array of meta information.

Events

livewire-filters-reset

livewire-filters-updated

When a filter is updated, it will emit this event with 2 arguments: key and payload. The key should be used in identifying which filter should be updated. The payload is the new value of the filter.

This event is automatically handled by the HasFilters trait. If you would like to customize how the updates are handled, you can listen for this event and use your own method or override the handleUpdateEvent method.

Making your own filters

In addition to the included filters, you can also make additional filters to suit your needs.

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] or [email protected] instead of using the issue tracker.

Credits

Sponsorship

Development of this package is sponsored by Kirschbaum, a developer driven company focused on problem solving, team building, and community. Learn more about us or join us!

License

The MIT License (MIT). Please see License File for more information.


All versions of livewire-filters with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
illuminate/contracts Version ^9.0|^10.0
illuminate/support Version ^9.0|^10.0
livewire/livewire Version ^2.10
spatie/laravel-package-tools Version ^1.9.2
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 kirschbaum-development/livewire-filters contains the following files

Loading the files please wait ....