diff --git a/src/Makes/MakeLayout.php b/src/Makes/MakeLayout.php index 7e65ac1..25077dc 100644 --- a/src/Makes/MakeLayout.php +++ b/src/Makes/MakeLayout.php @@ -26,20 +26,8 @@ public function __construct(ScaffoldMakeCommand $scaffoldCommand, Filesystem $fi protected function start() { - - if ($this->files->exists($path_resource = $this->getPathResource())) { - if ($this->scaffoldCommandObj->confirm($path_resource . ' already exists! Do you wish to overwrite? [yes|no]')) { - $this->putViewLayout($path_resource); - - $this->scaffoldCommandObj->info('Layout created successfully.'); - } else { - $this->scaffoldCommandObj->comment('Skip Layout, because already exists.'); - } - } else { - $this->putViewLayout($path_resource); - } - - + $this->putViewLayout('Layout', 'stubs/html_assets/layout.stub', 'layout.blade.php'); + $this->putViewLayout('Error', 'stubs/html_assets/error.stub', 'error.blade.php'); } @@ -47,11 +35,19 @@ protected function start() * @param $path_resource * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ - protected function putViewLayout($path_resource) + protected function putViewLayout($name, $stub, $file) { - // Copy layout blade bootstrap 3 to resoures - $layout_html = $this->files->get(__DIR__ . '/../stubs/html_assets/layout.stub'); - $this->files->put($path_resource, $layout_html); + $path_file = $this->getPathResource().$file; + $path_stub = __DIR__ .'/../'.$stub; + + if (!$this->files->exists($path_file)){ + $html = $this->files->get($path_stub); + $this->files->put($path_file, $html); + + $this->scaffoldCommandObj->info("$name created successfully."); + }else{ + $this->scaffoldCommandObj->comment("Skip $name, because already exists."); + } } @@ -63,8 +59,6 @@ protected function putViewLayout($path_resource) */ protected function getPathResource() { - - return './resources/views/layout.blade.php'; - + return './resources/views/'; } } \ No newline at end of file diff --git a/src/stubs/html_assets/error.stub b/src/stubs/html_assets/error.stub new file mode 100644 index 0000000..166b234 --- /dev/null +++ b/src/stubs/html_assets/error.stub @@ -0,0 +1,10 @@ +@if (count($errors) > 0) +
There were some problems with your input.
+