FEATURE: use even more route model binding

This commit is contained in:
Michal Kváček
2017-08-01 19:51:12 +02:00
parent 3275e5aeed
commit 2d60010f9e
16 changed files with 158 additions and 100 deletions
@@ -34,13 +34,8 @@ class EditTemplate extends Controller
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function getEdit($template)
public function getEdit(Template $template)
{
/**
* @var $template Template
*/
$template = Template::findOrFail($template);
$this->templateRepository->setModel($template);
// load template content
@@ -59,15 +54,13 @@ class EditTemplate extends Controller
* Save meta information about template and edited content
*
* @param EditTemplateRequest $request
* @param $templateId
* @param Template $template
*
* @return \Illuminate\Http\RedirectResponse
* @internal param $templateId
*/
public function postEdit(EditTemplateRequest $request, $templateId)
public function postEdit(EditTemplateRequest $request, Template $template)
{
// find template
$template = Template::findOrFail($templateId);
// setup meta information
$template->name = $request->name;
@@ -7,16 +7,21 @@ use App\Models\Templates\TemplatePath;
class TemplateOverview extends Controller
{
public function getPath($path)
/**
* Display overview of all templates in given path
*
* @param TemplatePath $templatePath
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function getPath(TemplatePath $templatePath)
{
$path = TemplatePath::findOrFail($path);
return view('admin.templates.list', [
'directory' => $path,
'isWritable' => is_writable(base_path($path->path)),
'templates' => $path->templates()
'directory' => $templatePath,
'isWritable' => is_writable(base_path($templatePath->path)),
'templates' => $templatePath->templates()
->get(),
'subdirectories' => $path->subdirectories()
'subdirectories' => $templatePath->subdirectories()
->get()
]);
}