public function delete(Request $request, $id) { $category = Category::findOrFail($id); $title = $category->title; $category->delete(); return redirect()->route('admin.post.category.index')->with('messages', ['Category ' . $title . ' is successfully deleted.']); }
public function resourcePost($slug) { $qb = PostTranslation::with('post')->whereSlug($slug); $postTranslation = $qb->firstOrFail(); $post = $postTranslation->post()->published()->firstOrFail(); $title = $post->title; $categories = Category::with(['translations', 'postsCount'])->get(); return view('frontend.page.resources.post', ['post' => $post, 'categories' => $categories, 'title' => $title]); }
protected function getCategoryOptions($lang) { $categories = Category::all(); $categoryOptions = []; foreach ($categories as $category) { $translation = $category->translate($lang, true); $categoryOptions[$category->id] = $translation->title; } return $categoryOptions; }
public function resourceCategories() { $categories = Category::all(); $content = view('frontend.sitemap.resource_categories', ['categories' => $categories])->render(); return response($content, 200)->header('Content-Type', 'text/xml'); }