Skip to content

Commit

Permalink
Merge pull request #1393 from Eroha186/fix_moonshine_policy_commnand
Browse files Browse the repository at this point in the history
fix: Moonshine command for create policy class
  • Loading branch information
lee-to authored Dec 19, 2024
2 parents f7466aa + 1bb331e commit e5f42fc
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/Commands/MakePolicyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ 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(),
required: true,
);
}

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

0 comments on commit e5f42fc

Please sign in to comment.