public function search() { $key = Input::get('key'); $id = Article::max('id'); for ($cnt = 1; $id > 0; $id--) { $article = Article::find($id); if (stripos($article['title'], $key) || stripos($article['text'], $key)) { $articles[$cnt] = $article; $cnt++; } else { if (stristr($article['tags'], $key)) { $articles[$cnt] = $article; $cnt++; } } if ($id == 1 && $cnt == 1) { $articles[$cnt] = null; } } foreach ($articles as $article) { $str = explode('__more__', $article['text']); $article['text'] = (string) $str[0]; } // return view('article.search', compact('articles')); if ($articles['1'] == null) { return view('errors.search_404'); } else { return view('article.search', compact('articles')); } // return $articles; }
public function showArticleByYear($year) { $maxYear = (int) substr(Article::max('created_at'), 0, 4); $minYear = (int) substr(Article::min('created_at'), 0, 4); $between = $this->getYearsBetween($year); $articles = Article::whereBetween('created_at', $between)->orderBy('id', 'DESC')->get(); $lenght = count($articles) / 10; $imageDir = $this->parseData($articles); return view('article', compact('articles', 'lenght', 'imageDir', 'maxYear', 'minYear')); }