Ejemplo n.º 1
0
 /**
  * Handle the event.
  *
  * @param  Create $event
  * @return void
  */
 public function handle(Create $event)
 {
     $event = $event->details;
     $special = [];
     if ($event->slug != null) {
         $special['slug'] = $event->slug;
     } else {
         $special['slug'] = str_slug($event->title);
     }
     $post = Posts::create(['title' => $event->title, 'content' => $event->title, 'header_image' => $event->event_image, 'slug' => $special['slug']]);
     if ($event->publish) {
         event(new Publish($post->id));
     }
 }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
0
 public function getPostToUpdate($id)
 {
     $post = Posts::whereId($id)->first();
     return \Theme::view('admin.posts.update', ['post' => $post]);
 }