Skip to content

Commit

Permalink
add Form and Table to prevent collision while creating a resource
Browse files Browse the repository at this point in the history
  • Loading branch information
borjajimnz committed Jan 4, 2025
1 parent 2bbfeeb commit 020f2a4
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/panels/src/Commands/MakeResourceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ class_exists($potentialCluster) &&
'formSchema' => $this->indentString($this->option('generate') ? $this->getResourceFormSchema(
$modelNamespace . ($modelSubNamespace !== '' ? "\\{$modelSubNamespace}" : '') . '\\' . $modelClass,
) : '//', 4),
'model' => ($model === 'Resource') ? "{$modelNamespace}\\Resource as ResourceModel" : "{$modelNamespace}\\{$model}",
'modelClass' => ($model === 'Resource') ? 'ResourceModel' : $modelClass,
...$this->generateModel($model, $modelNamespace, $modelClass),
'namespace' => $namespace,
'pages' => $this->indentString($pages, 3),
'relations' => $this->indentString($relations, 1),
Expand Down Expand Up @@ -324,4 +323,20 @@ class_exists($potentialCluster) &&

return static::SUCCESS;
}

protected function generateModel(string $model, string $modelNamespace, string $modelClass): array

Check failure on line 327 in packages/panels/src/Commands/MakeResourceCommand.php

View workflow job for this annotation

GitHub Actions / P8.3 - L11.* - prefer-stable

Method Filament\Commands\MakeResourceCommand::generateModel() return type has no value type specified in iterable type array.

Check failure on line 327 in packages/panels/src/Commands/MakeResourceCommand.php

View workflow job for this annotation

GitHub Actions / P8.3 - L10.* - prefer-stable

Method Filament\Commands\MakeResourceCommand::generateModel() return type has no value type specified in iterable type array.

Check failure on line 327 in packages/panels/src/Commands/MakeResourceCommand.php

View workflow job for this annotation

GitHub Actions / P8.2 - L11.* - prefer-stable

Method Filament\Commands\MakeResourceCommand::generateModel() return type has no value type specified in iterable type array.

Check failure on line 327 in packages/panels/src/Commands/MakeResourceCommand.php

View workflow job for this annotation

GitHub Actions / P8.2 - L10.* - prefer-stable

Method Filament\Commands\MakeResourceCommand::generateModel() return type has no value type specified in iterable type array.

Check failure on line 327 in packages/panels/src/Commands/MakeResourceCommand.php

View workflow job for this annotation

GitHub Actions / P8.1 - L10.* - prefer-stable

Method Filament\Commands\MakeResourceCommand::generateModel() return type has no value type specified in iterable type array.
{
$possibilities = ['Form', 'Table', 'Resource'];
$params = [];

if (in_array($model, $possibilities)) {
$params['model'] = "{$modelNamespace}\\{$model} as {$model}Model";
$params['modelClass'] = $model . 'Model';
} else {
$params['model'] = "{$modelNamespace}\\{$model}";
$params['modelClass'] = $modelClass;
}

return $params;
}
}

0 comments on commit 020f2a4

Please sign in to comment.