示例#1
0
 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]);
 }
示例#2
0
 public static function slug($slug)
 {
     return Post::where('slug', '=', $slug)->first();
 }
示例#3
0
 /**
  * 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.']);
 }