예제 #1
0
 /**
  * Get post collection.
  *
  * @param  string  $slug
  * @return array
  */
 public function show($slug)
 {
     $post = $this->model->with('user', 'tags')->whereSlug($slug)->firstOrFail();
     $comments = $this->comment->wherePost_id($post->id)->with('user')->whereHas('user', function ($q) {
         $q->whereValid(true);
     })->get();
     return compact('post', 'comments');
 }
예제 #2
0
 /**
  * Get post collection.
  *
  * @param  string $slug
  * @return array
  */
 public function show($slug)
 {
     // $post = $this->model->with('user', 'tags')->whereSlug($slug)->firstOrFail();
     if (\Cache::has('post' . $slug)) {
         $post = \Cache::get('post' . $slug);
     } else {
         $post = $this->model->with('user', 'category')->whereSlug($slug)->firstOrFail();
         \Cache::add('post' . $slug, $post, 1);
     }
     $comments = $this->comment->wherePost_id($post->id)->with('user')->whereHas('user', function ($q) {
         $q->whereValid(true);
     })->get();
     return compact('post', 'comments');
 }
예제 #3
0
 public function index(Post $post)
 {
     return Comment::wherePost_id($post->id)->orderBy("created_at", "desc")->paginate(Input::get("itemPerPage"));
 }