/** * Handle the command, retrieving the category and returning the result of the update operation * * @param UpdateCategoryCommand $command * @return Resource */ public function handle(ModifyCategoryCommand $command) { $category = $this->categories->getById($command->id); if (!empty($command->attributes['title'])) { $category->title = $command->attributes['title']; $category->slug = Slug::fromTitle($command->attributes['title']); } $category->description = $command->attributes['description'] ?: $category->description; return $this->categories->update($category, $command->attributes); }