Skip to content

Commit

Permalink
Fixed Laravel Data objects being handled form request extractor which…
Browse files Browse the repository at this point in the history
… results in error (#450)

* fix laravel data object being tried by form request extractor when extracting rules

* Fix styling

---------

Co-authored-by: romalytvynenko <romalytvynenko@users.noreply.github.com>
  • Loading branch information
romalytvynenko and romalytvynenko authored Jul 12, 2024
1 parent 6821dd2 commit 5b3afc1
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use PhpParser\Node\Param;
use PhpParser\NodeFinder;
use ReflectionClass;
use Spatie\LaravelData\Contracts\BaseData;

class FormRequestRulesExtractor
{
Expand All @@ -28,7 +29,17 @@ public function shouldHandle()
return false;
}

return collect($this->handler->getParams())->contains($this->findCustomRequestParam(...));
if (! collect($this->handler->getParams())->contains($this->findCustomRequestParam(...))) {
return false;
}

$className = $this->getFormRequestClassName();

if (is_a($className, BaseData::class, true)) {
return false;
}

return true;
}

public function node()
Expand Down

0 comments on commit 5b3afc1

Please sign in to comment.