Skip to content

Commit

Permalink
Added partial error
Browse files Browse the repository at this point in the history
  • Loading branch information
sylviot committed Oct 2, 2015
1 parent 3f75c23 commit 893d7c3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
36 changes: 15 additions & 21 deletions src/Makes/MakeLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,28 @@ 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');
}


/**
* @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.");
}
}


Expand All @@ -63,8 +59,6 @@ protected function putViewLayout($path_resource)
*/
protected function getPathResource()
{

return './resources/views/layout.blade.php';

return './resources/views/';
}
}
10 changes: 10 additions & 0 deletions src/stubs/html_assets/error.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@if (count($errors) > 0)
<div class="alert alert-danger">
<p>There were some problems with your input.</p>
<ul>
@foreach ($errors->all() as $error)
<li><i class="glyphicon glyphicon-remove"></i> {{ $error }}</li>
@endforeach
</ul>
</div>
@endif

0 comments on commit 893d7c3

Please sign in to comment.