public function showArticle($id) { $article = Article::find($id); return view('2016.article')->with('article', $article); }
private function createArticles($articles) { foreach ($articles as $article) { Article::create($this->generateArticle($article)); } }
/** * @param $operand * @param $year * @return mixed */ private function getArticlesForType($operand, $year, $type, $edition = null) { $articles = Article::orderBy('published_at', 'descending')->where('type', $type); if ($year) { $articles->where(DB::raw('extract(year from published_at)'), $operand, $year); } if ($edition) { $articles->where('edition', $edition); } foreach ($articles = $articles->get() as $article) { if ($article->image) { $article->image = env('ARTICLE_IMAGE_URL_BASE') . DIRECTORY_SEPARATOR . $article->image; $article->date = Carbon::createFromFormat('Y-m-d', $article->date)->format('d m Y'); } } return $articles; }