예제 #1
0
 /**
  * Get all post in a month
  * @param $year
  * @param $month
  * @return \Theme
  */
 public function getMonth($year, $month)
 {
     if (Posts::whereYear('created_at', '=', $year)->whereMonth('created_at', '=', $month)->where('published_at', '!=', null)->exists()) {
         if (!\Cache::has('post-' . $year . '-' . $month)) {
             $posts = Posts::whereYear('created_at', '=', $year)->whereMonth('created_at', '=', $month)->where('published_at', '!=', null)->orderBy('published_at', 'desc')->paginate();
             \Cache::put('posts-' . $year . '-' . $month, $posts, 5);
         } else {
             $posts = \Cache::get('posts-' . $year . '-' . $month);
         }
         return \Theme::view('blog.list', ['posts' => $posts]);
     } else {
         return abort(404);
     }
 }