Skip to content

Commit 893d7c3

Browse files
committed
Added partial error
1 parent 3f75c23 commit 893d7c3

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

src/Makes/MakeLayout.php

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,28 @@ public function __construct(ScaffoldMakeCommand $scaffoldCommand, Filesystem $fi
2626

2727
protected function start()
2828
{
29-
30-
if ($this->files->exists($path_resource = $this->getPathResource())) {
31-
if ($this->scaffoldCommandObj->confirm($path_resource . ' already exists! Do you wish to overwrite? [yes|no]')) {
32-
$this->putViewLayout($path_resource);
33-
34-
$this->scaffoldCommandObj->info('Layout created successfully.');
35-
} else {
36-
$this->scaffoldCommandObj->comment('Skip Layout, because already exists.');
37-
}
38-
} else {
39-
$this->putViewLayout($path_resource);
40-
}
41-
42-
29+
$this->putViewLayout('Layout', 'stubs/html_assets/layout.stub', 'layout.blade.php');
30+
$this->putViewLayout('Error', 'stubs/html_assets/error.stub', 'error.blade.php');
4331
}
4432

4533

4634
/**
4735
* @param $path_resource
4836
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
4937
*/
50-
protected function putViewLayout($path_resource)
38+
protected function putViewLayout($name, $stub, $file)
5139
{
52-
// Copy layout blade bootstrap 3 to resoures
53-
$layout_html = $this->files->get(__DIR__ . '/../stubs/html_assets/layout.stub');
54-
$this->files->put($path_resource, $layout_html);
40+
$path_file = $this->getPathResource().$file;
41+
$path_stub = __DIR__ .'/../'.$stub;
42+
43+
if (!$this->files->exists($path_file)){
44+
$html = $this->files->get($path_stub);
45+
$this->files->put($path_file, $html);
46+
47+
$this->scaffoldCommandObj->info("$name created successfully.");
48+
}else{
49+
$this->scaffoldCommandObj->comment("Skip $name, because already exists.");
50+
}
5551
}
5652

5753

@@ -63,8 +59,6 @@ protected function putViewLayout($path_resource)
6359
*/
6460
protected function getPathResource()
6561
{
66-
67-
return './resources/views/layout.blade.php';
68-
62+
return './resources/views/';
6963
}
7064
}

src/stubs/html_assets/error.stub

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@if (count($errors) > 0)
2+
<div class="alert alert-danger">
3+
<p>There were some problems with your input.</p>
4+
<ul>
5+
@foreach ($errors->all() as $error)
6+
<li><i class="glyphicon glyphicon-remove"></i> {{ $error }}</li>
7+
@endforeach
8+
</ul>
9+
</div>
10+
@endif

0 commit comments

Comments
 (0)