/**
  * Handle the command, creating a new category record and returning the result.
  *
  * @param CommandInterface $command
  * @return Category
  */
 public function handle(SetupCategoryCommand $command)
 {
     $category = $this->factory->create($command->title, $command->description);
     $this->categories->save($category);
     $this->dispatch($category->releaseEvents());
     return $category;
 }
 /**
  * @param View $view
  */
 public function compose(View $view)
 {
     $categories = $this->categories->getAll();
     $removeCategory = isset($view->category) ? $view->category->id : null;
     if ($categories->count()) {
         $view->with('categories', $categories->forSelect($removeCategory));
     }
 }
 /**
  * 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);
 }
 /**
  * @param View $view
  */
 public function compose(View $view)
 {
     $view->with('categories', $this->categories->getAll());
 }
 /**
  * Retrieves a list of the most recently updated discussions.
  *
  * @return mixed
  */
 public function index()
 {
     $discussions = $this->discussions->getRecent();
     $categoryCount = $this->categories->count();
     return $this->respond('home.index', compact('discussions', 'categoryCount'));
 }
 public function destroy($slug)
 {
     $category = $this->categories->getBySlug($slug);
     $this->categories->delete($category);
     return redirect()->route('category.index');
 }
 /**
  * @param DiscussionWasStarted $discussion
  */
 public function handle(\FloatingPoint\Grapevine\Modules\Discussions\Events\DiscussionWasStarted $discussion)
 {
     $this->categories->increaseDiscussionCount($discussion->categoryId);
 }