Skip to content

Commit

Permalink
Merge pull request #61 from CodeWithDennis/feature/introduce-get-form…
Browse files Browse the repository at this point in the history
…-methods

feat: Add methods to retrieve required fields for resource
  • Loading branch information
CodeWithDennis authored Mar 28, 2024
2 parents 5358e9a + 41d5d1a commit 7a780da
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Commands/FilamentResourceTestsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ protected function getStubContents(string $stub, array $stubVariables = []): arr
return $contents.PHP_EOL.PHP_EOL;
}

protected function getResourceRequiredCreateFields(Resource $resource): Collection
{
return collect($this->getResourceCreateForm($resource)->getFlatFields())
->filter(fn ($column) => $column->isRequired());
}

protected function getResourceRequiredEditFields(Resource $resource): Collection
{
return collect($this->getResourceEditForm($resource)->getFlatFields())
->filter(fn ($column) => $column->isRequired());
}

protected function getResourceCreateFields(Resource $resource): array
{
return $this->getResourceCreateForm($resource)->getFlatFields();
Expand Down

0 comments on commit 7a780da

Please sign in to comment.