コード例 #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
ファイル: NewsRepo.php プロジェクト: sidis405/uniamo
 public function getById($id)
 {
     return News::with('categories', 'tags', 'user')->where('id', $id)->first();
 }