Browse Source

Fixed after make:crud (full) usage failure on laravel 5.5

tags/1.0.0
Nafies Luthfi 8 years ago
parent
commit
7c1ed11bce
  1. 1
      src/GeneratorCommand.php
  2. 4
      src/stubs/controller.full.stub
  3. 2
      src/stubs/view-index-full.stub
  4. 12
      tests/Generators/FullControllerGeneratorTest.php
  5. 2
      tests/Generators/ViewsGeneratorTest.php

1
src/GeneratorCommand.php

@ -102,6 +102,7 @@ class GeneratorCommand extends Command
{
$appNamespace = trim($this->getAppNamespace(), '\\');
$modelNamespace = str_replace('/', '\\', $appNamespace.'/'.ucfirst($modelPath));
$modelNamespace = trim($modelNamespace, '\\');
return $modelNamespace == 'App\\' ? 'App' : $modelNamespace;
}

4
src/stubs/controller.full.stub

@ -51,9 +51,9 @@ class MastersController extends Controller
'description' => 'nullable|max:255',
]);
Master::create($request->only('name', 'description'));
$singleMstr = Master::create($request->only('name', 'description'));
return redirect()->route('masters.index');
return redirect()->route('masters.show', $singleMstr);
}
/**

2
src/stubs/view-index-full.stub

@ -6,7 +6,7 @@
<h1 class="page-header">
<div class="pull-right">
@can('create', new fullMstr)
{{ link_to_route('masters.index', trans('master.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }}
{{ link_to_route('masters.create', trans('master.create'), [], ['class' => 'btn btn-success']) }}
@endcan
</div>
{{ trans('master.list') }}

12
tests/Generators/FullControllerGeneratorTest.php

@ -65,9 +65,9 @@ class {$this->plural_model_name}Controller extends Controller
'description' => 'nullable|max:255',
]);
{$this->model_name}::create(\$request->only('name', 'description'));
\${$this->single_model_var_name} = {$this->model_name}::create(\$request->only('name', 'description'));
return redirect()->route('{$this->table_name}.index');
return redirect()->route('{$this->table_name}.show', \${$this->single_model_var_name});
}
/**
@ -201,9 +201,9 @@ class CategoriesController extends Controller
'description' => 'nullable|max:255',
]);
Category::create(\$request->only('name', 'description'));
\$category = Category::create(\$request->only('name', 'description'));
return redirect()->route('categories.index');
return redirect()->route('categories.show', \$category);
}
/**
@ -338,9 +338,9 @@ class CategoriesController extends Controller
'description' => 'nullable|max:255',
]);
Category::create(\$request->only('name', 'description'));
\$category = Category::create(\$request->only('name', 'description'));
return redirect()->route('categories.index');
return redirect()->route('categories.show', \$category);
}
/**

2
tests/Generators/ViewsGeneratorTest.php

@ -22,7 +22,7 @@ class ViewsGeneratorTest extends TestCase
<h1 class=\"page-header\">
<div class=\"pull-right\">
@can('create', new {$this->full_model_name})
{{ link_to_route('{$this->table_name}.index', trans('{$this->lang_name}.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }}
{{ link_to_route('{$this->table_name}.create', trans('{$this->lang_name}.create'), [], ['class' => 'btn btn-success']) }}
@endcan
</div>
{{ trans('{$this->lang_name}.list') }}

Loading…
Cancel
Save