Exemplo n.º 1
0
 public function showArticle($id)
 {
     $article = Article::find($id);
     return view('2016.article')->with('article', $article);
 }
Exemplo n.º 2
0
 private function createArticles($articles)
 {
     foreach ($articles as $article) {
         Article::create($this->generateArticle($article));
     }
 }
Exemplo n.º 3
0
 /**
  * @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;
 }