public function post($slug) { $post = Post::where('slug', '=', $slug)->firstOrFail(); $post->load('category', 'tags', 'user', 'comments'); $totalComments = $post->comments->count(); return view('pages.post')->with(['post' => $post, 'totalComments' => $totalComments]); }
public static function slug($slug) { return Post::where('slug', '=', $slug)->first(); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($slug) { $post = Post::where('slug', '=', $slug)->firstorFail(); $post->delete(); return redirect('admin/post')->with('message', ['class' => 'success', 'message' => 'Post deleted.']); }