From c9d735fa56d3b9abb0e63a9968432abd25a8ffb6 Mon Sep 17 00:00:00 2001 From: Vito Date: Tue, 5 Apr 2022 15:28:38 +0200 Subject: [PATCH 1/2] feat: add inbound option to CastMakeCommand --- .../Foundation/Console/CastMakeCommand.php | 17 +++++++++++++- .../Console/stubs/cast.inbound.stub | 22 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/Illuminate/Foundation/Console/stubs/cast.inbound.stub diff --git a/src/Illuminate/Foundation/Console/CastMakeCommand.php b/src/Illuminate/Foundation/Console/CastMakeCommand.php index f426cedf00d9..0e5fd9d39519 100644 --- a/src/Illuminate/Foundation/Console/CastMakeCommand.php +++ b/src/Illuminate/Foundation/Console/CastMakeCommand.php @@ -3,6 +3,7 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\GeneratorCommand; +use Symfony\Component\Console\Input\InputOption; class CastMakeCommand extends GeneratorCommand { @@ -45,7 +46,9 @@ class CastMakeCommand extends GeneratorCommand */ protected function getStub() { - return $this->resolveStubPath('/stubs/cast.stub'); + return $this->option('inbound') + ? $this->resolveStubPath('/stubs/cast.inbound.stub') + : $this->resolveStubPath('/stubs/cast.stub'); } /** @@ -71,4 +74,16 @@ protected function getDefaultNamespace($rootNamespace) { return $rootNamespace.'\Casts'; } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getOptions() + { + return [ + ['inbound', 'i', InputOption::VALUE_OPTIONAL, 'Generate an inbound cast class'], + ]; + } } diff --git a/src/Illuminate/Foundation/Console/stubs/cast.inbound.stub b/src/Illuminate/Foundation/Console/stubs/cast.inbound.stub new file mode 100644 index 000000000000..c456e3c5679e --- /dev/null +++ b/src/Illuminate/Foundation/Console/stubs/cast.inbound.stub @@ -0,0 +1,22 @@ + Date: Tue, 5 Apr 2022 12:26:59 -0500 Subject: [PATCH 2/2] Update CastMakeCommand.php --- src/Illuminate/Foundation/Console/CastMakeCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/CastMakeCommand.php b/src/Illuminate/Foundation/Console/CastMakeCommand.php index 0e5fd9d39519..07c278e4f36e 100644 --- a/src/Illuminate/Foundation/Console/CastMakeCommand.php +++ b/src/Illuminate/Foundation/Console/CastMakeCommand.php @@ -83,7 +83,7 @@ protected function getDefaultNamespace($rootNamespace) protected function getOptions() { return [ - ['inbound', 'i', InputOption::VALUE_OPTIONAL, 'Generate an inbound cast class'], + ['inbound', null, InputOption::VALUE_OPTIONAL, 'Generate an inbound cast class'], ]; } }