Cachet/app/controllers/DashComponentController.php

89 lines
2.0 KiB
PHP
Raw Normal View History

<?php
2014-12-20 21:20:17 +00:00
class DashComponentController extends Controller
{
/**
* Shows the components view.
2014-12-29 23:07:46 +00:00
*
2014-12-20 21:20:17 +00:00
* @return \Illuminate\View\View
*/
public function showComponents()
{
$components = Component::all();
2014-12-20 21:20:17 +00:00
return View::make('dashboard.components')->with([
'pageTitle' => 'Components - Dashboard',
'components' => $components,
]);
}
2014-12-20 21:20:17 +00:00
/**
* Shows the edit component view.
2014-12-29 23:07:46 +00:00
*
* @param \Component $component
*
2014-12-20 21:20:17 +00:00
* @return \Illuminate\View\View
*/
public function showEditComponent(Component $component)
{
return View::make('dashboard.component-edit')->with([
'pageTitle' => 'Editing "'.$component->name.'" Component - Dashboard',
'component' => $component,
]);
}
2014-12-20 20:40:48 +00:00
2014-12-20 21:20:17 +00:00
/**
* Updates a component.
2014-12-29 23:07:46 +00:00
*
* @param \Component $component
*
2014-12-20 21:20:17 +00:00
* @return \Illuminate\Http\RedirectResponse
*/
public function updateComponentAction(Component $component)
{
$_component = Input::get('component');
$component->update($_component);
2014-12-20 20:40:48 +00:00
2014-12-20 21:20:17 +00:00
return Redirect::back()->with('savedComponent', $component);
}
2014-12-20 20:40:48 +00:00
2014-12-20 21:20:17 +00:00
/**
* Shows the add component view.
2014-12-29 23:07:46 +00:00
*
2014-12-20 21:20:17 +00:00
* @return \Illuminate\View\View
*/
public function showAddComponent()
{
return View::make('dashboard.component-add')->with([
'pageTitle' => 'Add Component - Dashboard',
]);
}
2014-12-20 20:40:48 +00:00
2014-12-20 21:20:17 +00:00
/**
* Creates a new component.
2014-12-29 23:07:46 +00:00
*
2014-12-20 21:20:17 +00:00
* @return \Illuminate\Http\RedirectResponse
*/
public function createComponentAction()
{
$_component = Input::get('component');
$component = Component::create($_component);
2014-12-20 21:20:17 +00:00
return Redirect::back()->with('component', $component);
}
2014-12-20 21:20:17 +00:00
/**
* Deletes a given component.
2014-12-29 23:07:46 +00:00
*
* @param \Component $component
*
2014-12-20 21:20:17 +00:00
* @return \Illuminate\Http\RedirectResponse
*/
public function deleteComponentAction(Component $component)
{
$component->delete();
2014-12-20 21:20:17 +00:00
return Redirect::back();
}
}