Added AddComponentGroupCommand

This commit is contained in:
James Brooks
2015-08-30 21:37:29 +01:00
parent 698b05980d
commit 6ee697cf7f
6 changed files with 103 additions and 7 deletions

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Http\Controllers\Api;
use CachetHQ\Cachet\Commands\ComponentGroup\AddComponentGroupCommand;
use CachetHQ\Cachet\Commands\ComponentGroup\RemoveComponentGroupCommand;
use CachetHQ\Cachet\Models\ComponentGroup;
use Exception;
@@ -56,10 +57,11 @@ class ComponentGroupController extends AbstractApiController
*/
public function postGroups()
{
$groupData = array_filter(Binput::only(['name', 'order']));
try {
$group = ComponentGroup::create($groupData);
$group = $this->dispatch(new AddComponentGroupCommand(
Binput::get('name'),
Binput::get('order', 0)
));
} catch (Exception $e) {
throw new BadRequestHttpException();
}
@@ -81,7 +83,6 @@ class ComponentGroupController extends AbstractApiController
try {
$group->update($groupData);
} catch (Exception $e) {
dd($e->getMessage());
throw new BadRequestHttpException();
}