8
8
9
9
trait FilterHelpers
10
10
{
11
- /**
12
- * @param string $column
13
- * @param string $value
14
- * @return array
15
- */
16
11
public function getFiltersStatus (): bool
17
12
{
18
13
return $ this ->filtersStatus ;
19
14
}
20
15
21
- /**
22
- * @param string $column
23
- * @param string $value
24
- * @return array
25
- */
26
16
public function filtersAreEnabled (): bool
27
17
{
28
18
return $ this ->getFiltersStatus () === true ;
29
19
}
30
20
31
- /**
32
- * @param string $column
33
- * @param string $value
34
- * @return array
35
- */
36
21
public function filtersAreDisabled (): bool
37
22
{
38
23
return $ this ->getFiltersStatus () === false ;
39
24
}
40
25
41
- /**
42
- * @param string $column
43
- * @param string $value
44
- * @return array
45
- */
46
26
public function getFiltersVisibilityStatus (): bool
47
27
{
48
28
return $ this ->filtersVisibilityStatus ;
49
29
}
50
30
51
- /**
52
- * @param string $column
53
- * @param string $value
54
- * @return array
55
- */
56
31
public function filtersVisibilityIsEnabled (): bool
57
32
{
58
33
return $ this ->getFiltersVisibilityStatus () === true ;
59
34
}
60
35
61
- /**
62
- * @param string $column
63
- * @param string $value
64
- * @return array
65
- */
66
36
public function filtersVisibilityIsDisabled (): bool
67
37
{
68
38
return $ this ->getFiltersVisibilityStatus () === false ;
69
39
}
70
40
71
- /**
72
- * @param string $column
73
- * @param string $value
74
- * @return array
75
- */
76
41
public function getFilterPillsStatus (): bool
77
42
{
78
43
return $ this ->filterPillsStatus ;
79
44
}
80
45
81
- /**
82
- * @param string $column
83
- * @param string $value
84
- * @return array
85
- */
86
46
public function filterPillsAreEnabled (): bool
87
47
{
88
48
return $ this ->getFilterPillsStatus () === true ;
89
49
}
90
50
91
- /**
92
- * @param string $column
93
- * @param string $value
94
- * @return array
95
- */
96
51
public function filterPillsAreDisabled (): bool
97
52
{
98
53
return $ this ->getFilterPillsStatus () === false ;
99
54
}
100
55
101
- /**
102
- * @param string $column
103
- * @param string $value
104
- * @return array
105
- */
106
56
public function hasFilters (): bool
107
57
{
108
58
return $ this ->getFilters ()->count ();
109
59
}
110
60
111
- /**
112
- * @param string $column
113
- * @param string $value
114
- * @return array
115
- */
116
61
public function getFilters (): Collection
117
62
{
118
63
return collect ($ this ->filters ());
119
64
}
120
65
121
- /**
122
- * @param string $column
123
- * @param string $value
124
- * @return array
125
- */
126
66
public function getFiltersCount (): int
127
67
{
128
68
return $ this ->getFilters ()->count ();
129
69
}
130
70
131
- /**
132
- * @param string $column
133
- * @param string $value
134
- * @return array
135
- */
136
71
public function getFilterByKey (string $ key )
137
72
{
138
73
return $ this ->getFilters ()->first (function ($ filter ) use ($ key ) {
139
74
return $ filter ->getKey () === $ key ;
140
75
});
141
76
}
142
77
143
- /**
144
- * @param string $column
145
- * @param string $value
146
- * @return array
147
- */
148
78
public function setFilter (string $ filterKey , $ value )
149
79
{
150
80
return $ this ->{$ this ->getTableName ()}['filters ' ][$ filterKey ] = $ value ;
151
81
}
152
82
153
- /**
154
- * @param string $column
155
- * @param string $value
156
- * @return array
157
- */
158
83
public function selectAllFilterOptions (string $ filterKey ): void
159
84
{
160
85
$ filter = $ this ->getFilterByKey ($ filterKey );
@@ -172,75 +97,40 @@ public function selectAllFilterOptions(string $filterKey): void
172
97
$ this ->setFilter ($ filterKey , array_keys ($ filter ->getOptions ()));
173
98
}
174
99
175
- /**
176
- * @param string $column
177
- * @param string $value
178
- * @return array
179
- */
180
100
public function setFilterDefaults (): void
181
101
{
182
102
foreach ($ this ->getFilters () as $ filter ) {
183
103
$ this ->resetFilter ($ filter );
184
104
}
185
105
}
186
106
187
- /**
188
- * @param string $column
189
- * @param string $value
190
- * @return array
191
- */
192
107
public function getAppliedFilters (): array
193
108
{
194
109
return $ this ->{$ this ->getTableName ()}['filters ' ] ?? [];
195
110
}
196
111
197
- /**
198
- * @param string $column
199
- * @param string $value
200
- * @return array
201
- */
202
112
public function hasAppliedFiltersWithValues (): bool
203
113
{
204
114
return count ($ this ->getAppliedFiltersWithValues ());
205
115
}
206
116
207
- /**
208
- * @param string $column
209
- * @param string $value
210
- * @return array
211
- */
212
117
public function getAppliedFiltersWithValues (): array
213
118
{
214
119
return array_filter ($ this ->getAppliedFilters (), function ($ item ) {
215
120
return is_array ($ item ) ? count ($ item ) : $ item !== null ;
216
121
});
217
122
}
218
123
219
- /**
220
- * @param string $column
221
- * @param string $value
222
- * @return array
223
- */
224
124
public function getAppliedFilterWithValue (string $ filterKey )
225
125
{
226
126
return $ this ->getAppliedFiltersWithValues ()[$ filterKey ] ?? null ;
227
127
}
228
128
229
- /**
230
- * @param string $column
231
- * @param string $value
232
- * @return array
233
- */
234
129
public function getAppliedFiltersWithValuesCount (): int
235
130
{
236
131
return count ($ this ->getAppliedFiltersWithValues ());
237
132
}
238
133
239
- /**
240
- * @param string $column
241
- * @param string $value
242
- * @return array
243
- */
244
134
public function resetFilter ($ filter ): void
245
135
{
246
136
if (! $ filter instanceof Filter) {
@@ -250,31 +140,16 @@ public function resetFilter($filter): void
250
140
$ this ->setFilter ($ filter ->getKey (), $ filter ->getDefaultValue ());
251
141
}
252
142
253
- /**
254
- * @param string $column
255
- * @param string $value
256
- * @return array
257
- */
258
143
public function getFilterLayout (): string
259
144
{
260
145
return $ this ->filterLayout ;
261
146
}
262
147
263
- /**
264
- * @param string $column
265
- * @param string $value
266
- * @return array
267
- */
268
148
public function isFilterLayoutPopover (): bool
269
149
{
270
150
return $ this ->getFilterLayout () === 'popover ' ;
271
151
}
272
152
273
- /**
274
- * @param string $column
275
- * @param string $value
276
- * @return array
277
- */
278
153
public function isFilterLayoutSlideDown (): bool
279
154
{
280
155
return $ this ->getFilterLayout () === 'slide-down ' ;
0 commit comments