From ef2486fe4a7bd8c1a52374ed3f0ed44a30fa6991 Mon Sep 17 00:00:00 2001 From: ousid Date: Thu, 10 Feb 2022 13:59:05 +0100 Subject: [PATCH 1/2] wip --- .../Concerns/InteractsWithConsoleCommands.php | 19 ++++++------------- tests/Commands/ModelMakeCommandTest.php | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/Console/Concerns/InteractsWithConsoleCommands.php b/src/Console/Concerns/InteractsWithConsoleCommands.php index 80266b5..611ed26 100644 --- a/src/Console/Concerns/InteractsWithConsoleCommands.php +++ b/src/Console/Concerns/InteractsWithConsoleCommands.php @@ -16,7 +16,12 @@ trait InteractsWithConsoleCommands */ public function loopThroughNameArgumentWith(string $command): bool { - collect($this->argument('name'))->each(function ($name, $key) use ($command) { + /** + * @var array $models + */ + $models = explode(' ', strval($this->argument('name'))); + + collect($models)->each(function ($name) use ($command) { $this->line("Generating {$name} class\n"); $this->call( @@ -37,18 +42,6 @@ public function loopThroughNameArgumentWith(string $command): bool return true; } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments(): array - { - return [ - ['name', InputArgument::IS_ARRAY, 'The name of the class'], - ]; - } - /** * Get the list of options * diff --git a/tests/Commands/ModelMakeCommandTest.php b/tests/Commands/ModelMakeCommandTest.php index 328dbfd..af5f90b 100644 --- a/tests/Commands/ModelMakeCommandTest.php +++ b/tests/Commands/ModelMakeCommandTest.php @@ -1,5 +1,19 @@ artisan('laracommand:make-model', [ + 'name' => 'Category', + ]) + ->assertExitCode(0); +}); + +it('returns required error if the name was not provided', function () { + $this->artisan('laracommand:make-model', [ + 'name' => null, + ]) + ->assertExitCode(0); +}); + it('creates a new eloquent model class', function () { $this->artisan('laracommand:make-model', [ 'name' => 'Category Product', From d02118faf400c488633763e7f74f74285d95a47b Mon Sep 17 00:00:00 2001 From: ousid Date: Thu, 10 Feb 2022 12:59:47 +0000 Subject: [PATCH 2/2] Fix styling --- src/Console/Concerns/InteractsWithConsoleCommands.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Console/Concerns/InteractsWithConsoleCommands.php b/src/Console/Concerns/InteractsWithConsoleCommands.php index 611ed26..4626485 100644 --- a/src/Console/Concerns/InteractsWithConsoleCommands.php +++ b/src/Console/Concerns/InteractsWithConsoleCommands.php @@ -2,8 +2,6 @@ namespace Coderflex\LaraCommand\Console\Concerns; -use Symfony\Component\Console\Input\InputArgument; - /** * Interact With Console Commands */