@@ -11,27 +11,26 @@ class ScheduleStatusFilter implements Filter
11
11
{
12
12
/**
13
13
* @param ScheduleBuilder $query
14
- * @param $value
15
- * @param string $property
16
14
* @return void
17
15
*/
18
16
public function __invoke (Builder $ query , $ value , string $ property )
19
17
{
20
18
if (is_array ($ value )) {
21
19
$ this ->multiValueFilter ($ value , $ query );
22
- return ;
20
+
21
+ return ;
23
22
}
24
23
$ enum = $ this ->toEnum ($ value );
25
24
if (! $ enum instanceof ScheduleStatusEnum) {
26
- return ;
25
+ return ;
27
26
}
28
27
$ this ->toQuery ($ enum , $ query );
29
28
}
30
29
31
30
public function multiValueFilter (array $ value , ScheduleBuilder $ query )
32
31
{
33
32
$ query ->where (function (ScheduleBuilder $ query ) use ($ value ) {
34
- foreach ($ value as $ status ) {
33
+ foreach ($ value as $ status ) {
35
34
$ status = $ this ->toEnum ($ status );
36
35
if (! $ status instanceof ScheduleStatusEnum) {
37
36
continue ;
@@ -44,10 +43,9 @@ public function multiValueFilter(array $value, ScheduleBuilder $query)
44
43
});
45
44
}
46
45
47
-
48
46
protected function toQuery (ScheduleStatusEnum $ value , ScheduleBuilder $ query )
49
47
{
50
- match ($ value ) {
48
+ match ($ value ) {
51
49
ScheduleStatusEnum::complete => $ query ->inThePast (),
52
50
ScheduleStatusEnum::in_progress => $ query ->inProgress (),
53
51
ScheduleStatusEnum::upcoming => $ query ->inTheFuture (),
@@ -56,10 +54,10 @@ protected function toQuery(ScheduleStatusEnum $value, ScheduleBuilder $query)
56
54
57
55
protected function toEnum ($ value )
58
56
{
59
- if ( ! $ value instanceof ScheduleStatusEnum && is_numeric ($ value )) {
57
+ if ( ! $ value instanceof ScheduleStatusEnum && is_numeric ($ value )) {
60
58
return ScheduleStatusEnum::tryFrom ($ value );
61
59
}
60
+
62
61
return $ value ;
63
62
}
64
-
65
63
}
0 commit comments