public function deleteDelete($id) { $template = Template::find($id); if (is_null($template)) { return back()->withErrors('没有这个模板'); } elseif ($template->delete()) { return redirect('template/list')->with('status', '模板删除成功'); } else { return back()->withErrors('模板删除失败'); } }
public function postContent(Request $request) { $content = new Content(); $content->user_id = \Auth::user()->id; $content->slug = $request->input('title'); $content->fill($request->all()); $content->save(); $template = Template::find($request->input('template_id')); // make directory for content $contentDir = base_path() . $this->contentDir; if (!\File::exists($contentDir)) { \File::makeDirectory($contentDir, 755); } $contentDir = $contentDir . $content->id; \File::makeDirectory($contentDir, 755); $templateDir = base_path() . $this->templateDir . $template->slug; \File::copyDirectory($templateDir, $contentDir); return response()->json($content->id, 200); }
/** * Remove the specified resource from storage. * * @param int $id ID of the template to destroy * @return \Illuminate\Http\Response */ public function destroy($id) { // Load selected template $template = Template::find($id); if ($template == null) { return redirect()->route('dashboard.settings.templates.index')->with('message', 'Error: Template not found'); } // Check if any pages are hve this template assigned? $pagesCount = $template->Pages()->count(); // Don't delete if template is referenced if ($pagesCount != 0) { return redirect()->route('dashboard.settings.templates.index')->with('message', 'Unable to delete ' . $template->name . ', as one or more pages require it.'); } // Delete $template->delete(); return redirect()->route('dashboard.settings.templates.index')->with('message', 'Templete deleted successfully'); }
public function templateEditor(Template $templatesModel, $name, $id) { $template = Template::find($id); $templates = $templatesModel->getTemplate(); return view('order.template_editor')->with('template', $template)->with('templates', $templates); }
public function showContent($id) { $template = Template::find($id); return \View::make('admin.template.content_template')->withTemplate($template); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $article = Article::find($id); $pageTitle = 'Update Department: ' . $article->display_name; $article->category_name = Category::find($article->category_id)->display_name; $article->template = $article->template_id != 0 ? Template::find($article->template_id)->toArray() : null; $article->sections = $article->articleSections()->get()->toArray(); return view('home.articles.edit', compact('pageTitle', 'article')); }
private function getMainArticles($article) { $mainArticles = ''; if ($article->template_id == 0) { // without template $articleSection = DB::table('article_sections')->where('article_id', $article->id)->first()->content; $mainArticles = $mainArticles . $articleSection; } else { // with template $template = Template::find($article->template_id); $templateSections = $template->templateSections()->get(); foreach ($templateSections as $templateSection) { if ($templateSection->is_editable == 0) { $mainArticles = $mainArticles . $templateSection->content; } else { $articleSection = DB::table('article_sections')->where(array('template_section_id' => $templateSection->id, 'article_id' => $article->id))->first()->content; $mainArticles = $mainArticles . $articleSection; } } } return $mainArticles; }
public function getTemplate($templateId) { $template = Template::find($templateId)->toArray(); $templateSections = DB::table('template_sections')->where('template_id', $templateId)->get(); $template['sections'] = $templateSections; return $template; }