diff --git a/backend/app/Console/Commands/MakeDtoCommand.php b/backend/app/Console/Commands/MakeDtoCommand.php new file mode 100644 index 0000000..2a5005d --- /dev/null +++ b/backend/app/Console/Commands/MakeDtoCommand.php @@ -0,0 +1,63 @@ +option('output')) { + return base_path('stubs/dto.output.stub'); + } + + return base_path('stubs/dto.input.stub'); + } + + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace + */ + protected function getDefaultNamespace($rootNamespace): string + { + return $rootNamespace.'\Data'; + } + + /** + * Get the console command options. + */ + protected function getOptions(): array + { + return [ + ['input', 'i', InputOption::VALUE_NONE, 'Generate an Input DTO (default)'], + ['output', 'o', InputOption::VALUE_NONE, 'Generate an Output DTO'], + ]; + } +} diff --git a/backend/stubs/dto.input.stub b/backend/stubs/dto.input.stub new file mode 100644 index 0000000..184901f --- /dev/null +++ b/backend/stubs/dto.input.stub @@ -0,0 +1,30 @@ + + */ + public function toArray(): array + { + return [ + // TODO: Map properties to array + ]; + } + + public static function fromRequest(FormRequest $request): InputDataTransferObject + { + return new self( + // TODO: Map request data to properties + ); + } +} diff --git a/backend/stubs/dto.output.stub b/backend/stubs/dto.output.stub new file mode 100644 index 0000000..23c1d5b --- /dev/null +++ b/backend/stubs/dto.output.stub @@ -0,0 +1,30 @@ + + */ + public function toArray(): array + { + return [ + // TODO: Map properties to array + ]; + } + + public static function fromModel(Model $model): OutputDataTransferObject + { + return new self( + // TODO: Map model data to properties + ); + } +}