Files
cachet-docker/src/Controllers/DashAPIController.php
Graham Campbell 0b3042f34d Fixes
2015-01-01 16:18:24 +00:00

48 lines
1.1 KiB
PHP

<?php
namespace CachetHQ\Cachet\Controllers;
use Component;
use Exception;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Input;
class DashAPIController extends Controller
{
/**
* Updates a component with the entered info.
*
* @param \Component $component
*
* @throws \Exception
*
* @return \Component
*/
public function postUpdateComponent(Component $component)
{
if (!$component->update(Input::except(['_token']))) {
throw new Exception('Failed to update the component.');
}
return $component;
}
/**
* Updates a components ordering.
*
* @return array
*/
public function postUpdateComponentOrder()
{
$componentData = Input::all();
unset($componentData['component'][0]); // Remove random 0 index.
foreach ($componentData['component'] as $componentId => $order) {
$component = Component::find($componentId);
$component->update(['order' => $order]);
}
return $componentData;
}
}