Skip to content

Commit

Permalink
feat: add default boolean rule to scope filter
Browse files Browse the repository at this point in the history
  • Loading branch information
lindyhopchris committed Jun 26, 2024
1 parent aeedead commit 423c24f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Filters/Scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use LaravelJsonApi\Eloquent\Filters\Concerns\DeserializesValue;
use LaravelJsonApi\Eloquent\Filters\Concerns\IsSingular;
use LaravelJsonApi\Validation\Filters\ValidatedWithRules;
use LaravelJsonApi\Validation\Rules\JsonBoolean;

class Scope implements Filter
{
Expand Down Expand Up @@ -75,6 +76,18 @@ public function apply($query, $value)
);
}

/**
* @return array
*/
protected function defaultRules(): array
{
if ($this->asBool) {
return [(new JsonBoolean())->asString()];
}

return [];
}

/**
* @return string
*/
Expand Down

0 comments on commit 423c24f

Please sign in to comment.