Skip to content

Commit 423c24f

Browse files
committed
feat: add default boolean rule to scope filter
1 parent aeedead commit 423c24f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Filters/Scope.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use LaravelJsonApi\Eloquent\Filters\Concerns\DeserializesValue;
1717
use LaravelJsonApi\Eloquent\Filters\Concerns\IsSingular;
1818
use LaravelJsonApi\Validation\Filters\ValidatedWithRules;
19+
use LaravelJsonApi\Validation\Rules\JsonBoolean;
1920

2021
class Scope implements Filter
2122
{
@@ -75,6 +76,18 @@ public function apply($query, $value)
7576
);
7677
}
7778

79+
/**
80+
* @return array
81+
*/
82+
protected function defaultRules(): array
83+
{
84+
if ($this->asBool) {
85+
return [(new JsonBoolean())->asString()];
86+
}
87+
88+
return [];
89+
}
90+
7891
/**
7992
* @return string
8093
*/

0 commit comments

Comments
 (0)