This is the most basic example of what you can achieve with Livewire Filters in just a few minutes. Here, we are filtering a collection using five components:
An LfTextFilter to filter by the Title text field
An LfCheckboxFilter for the Car Brand taxonomy field
An LfRadioFilter for the Transmission select field
An LfSelectFilter for the Fuel Type select field
And an LfRadioFilter with buckets that turns the Price field into a list of price ranges
It also uses the Tag component and the default pagination component.
1<div class="my-8 xl:my-12" id="livewire-collection">
2 <div class="grid grid-cols-12 gap-8 lg:gap-12 xl:gap-16">
3 <div class="col-span-3">
4 <div class="mb-8">
5 <div class="mb-2 font-bold">
6 Search by name
7 </div>
8 {{ livewire:lf-text-filter
9 blueprint="cars.car"
10 field="title"
11 condition="contains"
12 }}
13 </div>
14 <div class="mb-8">
15 <div class="mb-2 font-bold">
16 Car brand
17 </div>
18 {{ livewire:lf-checkbox-filter
19 blueprint="cars.car"
20 field="car_brand"
21 condition="taxonomy"
22 }}
23 </div>
24 <div class="mb-8">
25 <div class="mb-2 font-bold">
26 Transmission
27 </div>
28 {{ livewire:lf-radio-filter
29 blueprint="cars.car"
30 field="transmission"
31 condition="is"
32 }}
33 </div>
34 <div class="mb-8">
35 <div class="mb-2 font-bold">
36 Fuel type
37 </div>
38 {{ livewire:lf-select-filter
39 blueprint="cars.car"
40 field="fuel_type"
41 condition="is"
42 }}
43 </div>
44 <div class="mb-8">
45 <div class="mb-2 font-bold">
46 Price
47 </div>
48 {{ price_labels = [
49 '0-12000' => 'Under €12,000',
50 '12000-16000' => '€12,000 to €16,000',
51 '16000-20000' => '€16,000 to €20,000',
52 '20000-' => '€20,000 and up'
53 ] }}
54 {{ livewire:lf-radio-filter
55 blueprint="cars.car"
56 field="price"
57 buckets="0-12000|12000-16000|16000-20000|20000-"
58 modifier="gte|lt"
59 :options="price_labels"
60 }}
61 </div>
62 </div>
63 <div class="col-span-9">
64 <div class="mb-4">
65 {{ livewire:lf-tags blueprint="cars.car" fields="title|car_brand|transmission|fuel_type|price" }}
66 </div>
67 <div>
68 {{ livewire-collection:cars paginate="9" scrollTo="#livewire-collection" }}
69 </div>
70 </div>
71 </div>
72</div>