Ejemplo n.º 1
0
 public function comment($slug)
 {
     $news2 = DB::table('news')->leftJoin('users', 'news.publisher', '=', 'users.id')->leftJoin('news_categories', 'news.category', '=', 'news_categories.id')->select('news.title', 'news.slug', 'news_categories.name as category', 'news.s_content', 'users.name as publisher', 'news.image', 'news.created_at', 'users.image as image2')->get();
     $news = News::where('slug', '=', $slug)->leftJoin('users', 'news.publisher', '=', 'users.id')->leftJoin('news_categories', 'news.category', '=', 'news_categories.id')->select('news.title', 'news.slug', 'news.category', 'news.s_content', 'news.content', 'users.name as publisher', 'news.image', 'news.created_at')->get();
     $com_id = News::first();
     $comment = new Comment();
     $comment->body = \Input::get('comment');
     $comment->poster = \Input::get('author');
     $comment->commentable_id = $com_id->id;
     $com_id->comments()->save($comment);
     return \Redirect::back()->with(['news' => $news, 'news2' => $news2]);
 }