/** * Handle the command. * * @param UpdatePageCommand $command * @return void */ public function handle(UpdatePageCommand $command) { $active = $command->active === 'on' ? 1 : 0; $page_object = Pages::edit($command->page_id, $command->title, $command->content, $active); $page = $this->repo->save($page_object); $page->categories()->sync($command->categories); $page->tags()->sync($command->tags); Event::fire(new PageWasUpdated($page)); return $page; }
public function getBySlug($slug) { return Pages::with('categories', 'tags')->where('slug', $slug)->first(); }