Пример #1
0
 /**
  * Handle the command.
  *
  * @param  CreateNewsCommand  $command
  * @return void
  */
 public function handle(CreateNewsCommand $command)
 {
     $active = $command->active === 'on' ? 1 : 0;
     $news_object = News::make($command->title, $command->excerpt, $command->body, $active);
     $news = $this->repo->save($news_object);
     $news->categories()->sync($command->categories);
     $news->tags()->sync($command->tags);
     $this->caricaImmagine($news, $command->image_path);
     Event::fire(new NewsWasCreated($news));
     return $news;
 }
Пример #2
0
 public function getById($id)
 {
     return News::with('categories', 'tags', 'user')->where('id', $id)->first();
 }