Ejemplo n.º 1
0
 /**
  * Get a single post
  * @param $year
  * @param $month
  * @param $slug
  * @return \Theme
  */
 public function getSlug($year, $month, $slug)
 {
     if (Posts::whereSlug($slug)->whereYear('created_at', '=', $year)->whereMonth('created_at', '=', $month)->where('published_at', '!=', null)->exists()) {
         if (!\Cache::has('posts-' . $year . '-' . $month . '-' . $slug)) {
             $post = Posts::whereSlug($slug)->whereYear('created_at', '=', $year)->whereMonth('created_at', '=', $month)->where('published_at', '!=', null)->first();
             \Cache::put('posts-' . $year . '-' . $month . '-' . $slug, $post, 5);
         } else {
             $post = \Cache::get('posts-' . $year . '-' . $month . '-' . $slug);
         }
         return \Theme::view('blog.single', ['post' => $post]);
     } else {
         return abort(404);
     }
 }