Skip to content

Commit

Permalink
fix: Moonshine command for create policy class
Browse files Browse the repository at this point in the history
  • Loading branch information
eroha186 committed Dec 18, 2024
1 parent 30583a3 commit 41ee624
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Commands/MakePolicyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ public function handle(): int
{
$modelPath = is_dir(app_path('Models')) ? app_path('Models') : app_path();

$className = suggest(
'Model',
collect((new Finder())->files()->depth(0)->in($modelPath))
->map(static fn ($file) => $file->getBasename('.php'))
->values()
->all()
);
if (! $className = $this->argument('className')) {
$className = suggest(
label: 'Model',
options: collect((new Finder())->files()->depth(0)->in($modelPath))
->map(static fn ($file) => $file->getBasename('.php'))
->values()
->all(),
);
}

$model = $this->qualifyModel($className);
$className = class_basename($model) . "Policy";
Expand Down

0 comments on commit 41ee624

Please sign in to comment.