/**
  * Handle the command.
  *
  * @param  CreateNewsCommand  $command
  * @return void
  */
 public function handle(CreateNewsCommand $command)
 {
     $news_object = News::make();
     $news = $this->repo->save($news_object);
     Event::fire(new NewsWasCreated($news));
     return $news;
 }
 /**
  * Handle the command.
  *
  * @param  UpdateNewsCommand  $command
  * @return void
  */
 public function handle(UpdateNewsCommand $command)
 {
     if ($command->fixed === 'on') {
         $this->repo->unpinAllNews();
         $fixed = '1';
     } else {
         $fixed = '0';
     }
     if ($command->published === 'on') {
         $published = '1';
     } else {
         $published = '0';
     }
     if ($command->featured_image_id < 1) {
         $published = 0;
         $fixed = 0;
     }
     $tags = count($command->tags) ? join(',', $command->tags) : null;
     $news_object = News::edit($command->news_id, $command->title, $command->subtitle, $command->news_id . '-' . str_slug($command->title), $command->excerpt, $command->body, $tags, $command->seo_description, $command->featured_image_id, $fixed, $published);
     // dd($news_object);
     $news = $this->repo->save($news_object);
     Event::fire(new NewsWasUpdated($news));
     return $news;
 }
Example #3
0
 public function remove($id)
 {
     $activity = News::find($id);
     $activity->delete();
     return true;
 }