File tree Expand file tree Collapse file tree 4 files changed +53
-3
lines changed Expand file tree Collapse file tree 4 files changed +53
-3
lines changed Original file line number Diff line number Diff line change 1
1
@if ($showSearch )
2
2
<div class =" mb-3 mb-md-0 input-group" >
3
3
<input
4
- wire:model.debounce.250ms =" filters.search"
4
+ wire:model{{ $this- >searchFilterOptions }} ="filters.search"
5
5
placeholder="{{ __ (' Search' ) } } "
6
6
type="text"
7
7
class="form-control"
Original file line number Diff line number Diff line change 1
1
@if ($showSearch )
2
2
<div class =" mb-3 mb-md-0 input-group" >
3
3
<input
4
- wire:model.debounce.250ms =" filters.search"
4
+ wire:model{{ $this- >searchFilterOptions }} ="filters.search"
5
5
placeholder="{{ __ (' Search' ) } } "
6
6
type="text"
7
7
class="form-control"
Original file line number Diff line number Diff line change 1
1
@if ($showSearch )
2
2
<div class =" flex rounded-md shadow-sm" >
3
3
<input
4
- wire:model.debounce.250ms =" filters.search"
4
+ wire:model{{ $this- >searchFilterOptions }} ="filters.search"
5
5
placeholder="{{ __ (' Search' ) } } "
6
6
type="text"
7
7
class="flex-1 shadow-sm border-cool-gray-300 block w-full transition duration-150 ease-in-out sm:text-sm sm:leading-5 focus:outline-none focus:border-indigo-300 focus:shadow-outline-indigo @if (isset ($filters [' search' ]) && strlen ($filters [' search' ]) ) rounded-none rounded-l-md @else rounded-md @endif "
Original file line number Diff line number Diff line change 7
7
*/
8
8
trait WithFilters
9
9
{
10
+ /**
11
+ * Filter values
12
+ *
13
+ * @var array
14
+ */
10
15
public array $ filters = [];
16
+
17
+ /**
18
+ * Map filter names
19
+ *
20
+ * @var array
21
+ */
11
22
public array $ filterNames = [];
23
+
24
+ /**
25
+ * Default filters
26
+ *
27
+ * @var array|null[]
28
+ */
12
29
public array $ baseFilters = [
13
30
'search ' => null ,
14
31
];
15
32
33
+ /**
34
+ * @var int
35
+ */
36
+ public ?int $ searchFilterDebounce = null ;
37
+
38
+ /**
39
+ * @var bool
40
+ */
41
+ public ?bool $ searchFilterLazy = null ;
42
+
43
+ /**
44
+ * @var bool
45
+ */
46
+ public ?bool $ searchFilterDefer = null ;
47
+
48
+ /**
49
+ * Build livewire model options for the search input
50
+ *
51
+ * @return string
52
+ */
53
+ public function getSearchFilterOptionsProperty ()
54
+ {
55
+ if ($ this ->searchFilterLazy ) {
56
+ return '.lazy ' ;
57
+ } elseif ($ this ->searchFilterDefer ) {
58
+ return '.defer ' ;
59
+ }elseif ($ this ->searchFilterDebounce ){
60
+ return '.debounce. ' . $ this ->searchFilterDebounce . 'ms ' ;
61
+ }else {
62
+ return '' ;
63
+ }
64
+ }
65
+
16
66
public function resetFilters (): void
17
67
{
18
68
$ search = $ this ->filters ['search ' ] ?? null ;
You can’t perform that action at this time.
0 commit comments