Merge pull request #191 from cachethq/component-reordering
Components can now be re-ordered, closes #165
This commit is contained in:
@@ -19,4 +19,24 @@ class DashAPIController extends Controller
|
||||
App::abort(500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class DashComponentController extends Controller
|
||||
*/
|
||||
public function showComponents()
|
||||
{
|
||||
$components = Component::all();
|
||||
$components = Component::orderBy('order')->orderBy('created_at')->get();
|
||||
|
||||
return View::make('dashboard.components.index')->with([
|
||||
'pageTitle' => 'Components - Dashboard',
|
||||
|
||||
@@ -28,8 +28,10 @@ class HomeController extends Controller
|
||||
*/
|
||||
public function showIndex()
|
||||
{
|
||||
$components = Component::orderBy('order')->orderBy('created_at')->get();
|
||||
|
||||
return View::make('index', [
|
||||
'components' => $this->component->all(),
|
||||
'components' => $components,
|
||||
'pageTitle' => Setting::get('app_name')
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user