File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
resources/views/components/tools/filters Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 10
10
id =" {{ $component -> getTableName () } } -filter-{{ $filter -> getKey () } }"
11
11
class =" block w-full transition duration-150 ease-in-out border-gray-300 rounded-md shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 dark:bg-gray-800 dark:text-white dark:border-gray-600"
12
12
>
13
+ @if ($filter -> getFirstOption () != " " )
14
+ <option @if ($filter -> isEmpty ($this ) ) selected @endif value =" all" >{{ $filter -> getFirstOption () } } </option >
15
+ @endif
13
16
@foreach ($filter -> getOptions () as $key => $value )
14
17
@if (is_iterable ($value ) )
15
18
<optgroup label =" {{ $key } }" >
@@ -30,6 +33,9 @@ class="block w-full transition duration-150 ease-in-out border-gray-300 rounded-
30
33
id =" {{ $component -> getTableName () } } -filter-{{ $filter -> getKey () } }"
31
34
class =" {{ $theme === ' bootstrap-4' ? ' form-control' : ' form-select' } }"
32
35
>
36
+ @if ($filter -> getFirstOption () != " " )
37
+ <option @if ($filter -> isEmpty ($this ) ) selected @endif value =" all" >{{ $filter -> getFirstOption () } } </option >
38
+ @endif
33
39
@foreach ($filter -> getOptions () as $key => $value )
34
40
@if (is_iterable ($value ) )
35
41
<optgroup label =" {{ $key } }" >
Original file line number Diff line number Diff line change 8
8
class MultiSelectDropdownFilter extends Filter
9
9
{
10
10
protected array $ options = [];
11
+ protected string $ firstOption = "" ;
11
12
12
13
public function options (array $ options = []): MultiSelectDropdownFilter
13
14
{
@@ -21,6 +22,19 @@ public function getOptions(): array
21
22
return $ this ->options ;
22
23
}
23
24
25
+
26
+ public function setFirstOption (string $ firstOption ): MultiSelectDropdownFilter
27
+ {
28
+ $ this ->firstOption = $ firstOption ;
29
+
30
+ return $ this ;
31
+ }
32
+
33
+ public function getFirstOption (): string
34
+ {
35
+ return $ this ->firstOption ;
36
+ }
37
+
24
38
public function getKeys (): array
25
39
{
26
40
return collect ($ this ->getOptions ())
@@ -67,7 +81,15 @@ public function getFilterPillValue($value): ?string
67
81
68
82
public function isEmpty ($ value ): bool
69
83
{
70
- return ! is_array ($ value );
84
+ if (!is_array ($ value ))
85
+ {
86
+ return true ;
87
+ }
88
+ else if (in_array ("all " , $ value ))
89
+ {
90
+ return true ;
91
+ }
92
+ return false ;
71
93
}
72
94
73
95
public function render (DataTableComponent $ component )
You can’t perform that action at this time.
0 commit comments