Skip to content

Commit

Permalink
Added excludes for generating models
Browse files Browse the repository at this point in the history
  • Loading branch information
zKoz210 committed Jun 10, 2024
1 parent b558106 commit 8e2a579
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions config/next-ide-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
*/
'overrides' => [],

/**
* Excluding some models for documentation generation.
*
* Excludes should be declared as follows :
* 'excludes' => [MyModel::class, AnotherModel::class]
*/
'excludes' => [],

/**
* Use Larastan friendly docblock when possible.
*/
Expand Down
13 changes: 13 additions & 0 deletions src/Console/ModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,19 @@ public function handle(FindModels $findModels): void

foreach ($this->resolvers($models) as $resolver) {
foreach ($models as $model) {
if ($this->isModelExcluded($model)) {
continue;
}

$resolver->execute($model);
}
}

foreach ($models as $model) {
if ($this->isModelExcluded($model)) {
continue;
}

foreach ($this->renderers($model) as $renderer) {
$renderer->render();
}
Expand Down Expand Up @@ -86,6 +94,11 @@ private function resolvers(ModelCollection $models): array
);
}

private function isModelExcluded(Model $model): bool
{
return in_array(get_class($model->instance()), config('next-ide-helper.models.excludes', []), true);
}

/**
* @return array<int, class-string<\Soyhuce\NextIdeHelper\Contracts\ModelResolver>>
*/
Expand Down

0 comments on commit 8e2a579

Please sign in to comment.