public function news($section, $newsId) { $news = News::findById($newsId); if (is_null($news)) { App::abort(404, 'Noticia no encontrada'); } $related = News::query()->where('section', '=', $news->section)->limit(0, 2)->get(); $user = User::get(); $comments = Comment::query()->where('newsId', '=', $newsId)->get(); return $this->base('news/news.t', array('comments' => $comments, 'user' => $user, 'news' => $news, 'related' => $related)); }
public function section($section) { $news = News::query()->where('section', '=', $section)->orderBy('created', 'DESC')->limit(0, 6)->get(); $col1 = array(); $col2 = array(); $featured = null; foreach ($news as $idx => $model) { if (is_null($featured)) { $featured = $model; continue; } if ($idx) { if ($idx % 2) { $col1[] = $model; } else { $col2[] = $model; } } } return $this->base('home/section.t', array('section' => $section, 'featured' => $featured, 'col1' => $col1, 'col2' => $col2)); }
public function news() { $news = News::query()->get(); return $this->base('admin/news.t', array('news' => $news)); }