Cachet/src/Http/Controllers/DashComponentController.php

97 lines
2.4 KiB
PHP
Raw Normal View History

<?php
namespace CachetHQ\Cachet\Http\Controllers;
2015-01-01 15:45:04 +00:00
use CachetHQ\Cachet\Models\Component;
2015-01-01 16:18:24 +00:00
use Illuminate\Routing\Controller;
2015-01-01 15:45:04 +00:00
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
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::orderBy('order')->orderBy('created_at')->get();
2015-01-01 10:39:22 +00:00
return View::make('dashboard.components.index')->with([
2014-12-20 21:20:17 +00:00
'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 \CachetHQ\Cachet\Models\Component $component
2014-12-29 23:07:46 +00:00
*
2014-12-20 21:20:17 +00:00
* @return \Illuminate\View\View
*/
public function showEditComponent(Component $component)
{
2015-01-01 10:39:22 +00:00
return View::make('dashboard.components.edit')->with([
2014-12-20 21:20:17 +00:00
'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 \CachetHQ\Cachet\Models\Component $component
2014-12-29 23:07:46 +00:00
*
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()
{
2015-01-01 10:39:22 +00:00
return View::make('dashboard.components.add')->with([
2014-12-20 21:20:17 +00:00
'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 \CachetHQ\Cachet\Models\Component $component
2014-12-29 23:07:46 +00:00
*
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();
}
}