public function delete(Request $request, $id) { $post = Post::findOrFail($id); $title = $post->title; $post->delete(); return redirect()->route('admin.post.index')->with('messages', ['Post ' . $title . ' is successfully deleted.']); }
public function resources() { $qb = Post::with('translations')->published()->orderBy('created_at', 'DESC'); $posts = $qb->get(); $content = view('frontend.sitemap.resources', ['posts' => $posts])->render(); return response($content, 200)->header('Content-Type', 'text/xml'); }
public function resources($category = null) { $qb = Post::with('translations')->published()->orderBy('created_at', 'DESC'); if ($category) { $categoryTranslation = CategoryTranslation::whereSlug($category)->firstOrFail(); $categoryObj = $categoryTranslation->category; $title = trans('resources.title') . ' - ' . $categoryObj->title; $qb->whereHas('categories', function ($q) use($categoryObj) { $q->where('category_id', $categoryObj->id); }); } else { $title = trans('resources.title'); } $posts = $qb->paginate(5); $categories = Category::with(['translations', 'postsCount'])->get(); return view('frontend.page.resources.category', ['paginator' => $posts, 'categories' => $categories, 'title' => $title]); }