Refactor validator stuff and fix variable names in views
This commit is contained in:
@@ -66,9 +66,7 @@ class ApiController extends AbstractController
|
||||
$groupData = Binput::get('ids');
|
||||
|
||||
foreach ($groupData as $order => $groupId) {
|
||||
ComponentGroup::find($groupId)->update([
|
||||
'order' => $order + 1,
|
||||
]);
|
||||
ComponentGroup::find($groupId)->update(['order' => $order + 1]);
|
||||
}
|
||||
|
||||
return $groupData;
|
||||
@@ -85,12 +83,10 @@ class ApiController extends AbstractController
|
||||
{
|
||||
$templateSlug = Binput::get('slug');
|
||||
|
||||
$template = IncidentTemplate::where('slug', $templateSlug)->first();
|
||||
|
||||
if ($template) {
|
||||
if ($template = IncidentTemplate::where('slug', $templateSlug)->first()) {
|
||||
return $template;
|
||||
}
|
||||
|
||||
throw new ModelNotFoundException('Incident template for '.$templateSlug.' could not be found.');
|
||||
throw new ModelNotFoundException("Incident template for $templateSlug could not be found.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Admin;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Http\Controllers\AbstractController;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
@@ -57,11 +58,10 @@ class ComponentController extends AbstractController
|
||||
|
||||
$this->subMenu['components']['active'] = true;
|
||||
|
||||
return View::make('dashboard.components.index')->with([
|
||||
'page_title' => trans_choice('dashboard.components.components', 2).' - '.trans('dashboard.dashboard'),
|
||||
'components' => $components,
|
||||
'sub_menu' => $this->subMenu,
|
||||
]);
|
||||
return View::make('dashboard.components.index')
|
||||
->withPageTitle(trans_choice('dashboard.components.components', 2).' - '.trans('dashboard.dashboard'))
|
||||
->withComponents($components)
|
||||
->withSubMenu($this->subMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,11 +73,10 @@ class ComponentController extends AbstractController
|
||||
{
|
||||
$this->subMenu['groups']['active'] = true;
|
||||
|
||||
return View::make('dashboard.components.groups.index')->with([
|
||||
'page_title' => trans_choice('dashboard.components.groups.groups', 2).' - '.trans('dashboard.dashboard'),
|
||||
'groups' => ComponentGroup::orderBy('order')->get(),
|
||||
'sub_menu' => $this->subMenu,
|
||||
]);
|
||||
return View::make('dashboard.components.groups.index')
|
||||
->withPageTitle(trans_choice('dashboard.components.groups.groups', 2).' - '.trans('dashboard.dashboard'))
|
||||
->withGroups(ComponentGroup::orderBy('order')->get())
|
||||
->withSubMenu($this->subMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,18 +90,12 @@ class ComponentController extends AbstractController
|
||||
{
|
||||
$groups = ComponentGroup::all();
|
||||
|
||||
$pageTitle = sprintf(
|
||||
'"%s" - %s - %s',
|
||||
$component->name,
|
||||
trans('dashboard.components.edit.title'),
|
||||
trans('dashboard.dashboard')
|
||||
);
|
||||
$pageTitle = sprintf('"%s" - %s - %s', $component->name, trans('dashboard.components.edit.title'), trans('dashboard.dashboard'));
|
||||
|
||||
return View::make('dashboard.components.edit')->with([
|
||||
'page_title' => $pageTitle,
|
||||
'component' => $component,
|
||||
'groups' => $groups,
|
||||
]);
|
||||
return View::make('dashboard.components.edit')
|
||||
->withPageTitle($pageTitle)
|
||||
->withComponent($component)
|
||||
->withGroups($groups);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,16 +110,13 @@ class ComponentController extends AbstractController
|
||||
$_component = Binput::get('component');
|
||||
$tags = array_pull($_component, 'tags');
|
||||
|
||||
$component->update($_component);
|
||||
|
||||
if (!$component->isValid()) {
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.components.edit.failure')
|
||||
))
|
||||
->with('errors', $component->getErrors());
|
||||
try {
|
||||
$component->update($_component);
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::all())
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.edit.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
// The component was added successfully, so now let's deal with the tags.
|
||||
@@ -134,20 +124,13 @@ class ComponentController extends AbstractController
|
||||
|
||||
// For every tag, do we need to create it?
|
||||
$componentTags = array_map(function ($taggable) use ($component) {
|
||||
return Tag::firstOrCreate([
|
||||
'name' => $taggable,
|
||||
])->id;
|
||||
return Tag::firstOrCreate(['name' => $taggable])->id;
|
||||
}, $tags);
|
||||
|
||||
$component->tags()->sync($componentTags);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.components.edit.success')
|
||||
);
|
||||
|
||||
return Redirect::back()->with('success', $successMsg);
|
||||
return Redirect::back()
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.edit.success')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,12 +140,9 @@ class ComponentController extends AbstractController
|
||||
*/
|
||||
public function showAddComponent()
|
||||
{
|
||||
$groups = ComponentGroup::all();
|
||||
|
||||
return View::make('dashboard.components.add')->with([
|
||||
'page_title' => trans('dashboard.components.add.title').' - '.trans('dashboard.dashboard'),
|
||||
'groups' => $groups,
|
||||
]);
|
||||
return View::make('dashboard.components.add')
|
||||
->withPageTitle(trans('dashboard.components.add.title').' - '.trans('dashboard.dashboard'))
|
||||
->withGroups(ComponentGroup::all());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,16 +156,13 @@ class ComponentController extends AbstractController
|
||||
// We deal with tags separately.
|
||||
$tags = array_pull($_component, 'tags');
|
||||
|
||||
$component = Component::create($_component);
|
||||
|
||||
if (!$component->isValid()) {
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.components.add.failure')
|
||||
))
|
||||
->with('errors', $component->getErrors());
|
||||
try {
|
||||
$component = Component::create($_component);
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::all())
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.add.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
// The component was added successfully, so now let's deal with the tags.
|
||||
@@ -193,20 +170,13 @@ class ComponentController extends AbstractController
|
||||
|
||||
// For every tag, do we need to create it?
|
||||
$componentTags = array_map(function ($taggable) use ($component) {
|
||||
return Tag::firstOrCreate([
|
||||
'name' => $taggable,
|
||||
])->id;
|
||||
return Tag::firstOrCreate(['name' => $taggable])->id;
|
||||
}, $tags);
|
||||
|
||||
$component->tags()->sync($componentTags);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.components.add.success')
|
||||
);
|
||||
|
||||
return Redirect::back()->with('success', $successMsg);
|
||||
return Redirect::back()
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.add.success')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,9 +203,7 @@ class ComponentController extends AbstractController
|
||||
public function deleteComponentGroupAction(ComponentGroup $group)
|
||||
{
|
||||
$group->components->map(function ($component) {
|
||||
$component->update([
|
||||
'group_id' => 0,
|
||||
]);
|
||||
$component->update(['group_id' => 0]);
|
||||
});
|
||||
|
||||
$group->delete();
|
||||
@@ -250,9 +218,8 @@ class ComponentController extends AbstractController
|
||||
*/
|
||||
public function showAddComponentGroup()
|
||||
{
|
||||
return View::make('dashboard.components.groups.add')->with([
|
||||
'page_title' => trans('dashboard.components.groups.add.title').' - '.trans('dashboard.dashboard'),
|
||||
]);
|
||||
return View::make('dashboard.components.groups.add')
|
||||
->withPageTitle(trans('dashboard.components.groups.add.title').' - '.trans('dashboard.dashboard'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,10 +231,9 @@ class ComponentController extends AbstractController
|
||||
*/
|
||||
public function showEditComponentGroup(ComponentGroup $group)
|
||||
{
|
||||
return View::make('dashboard.components.groups.edit')->with([
|
||||
'page_title' => trans('dashboard.components.groups.edit.title').' - '.trans('dashboard.dashboard'),
|
||||
'group' => $group,
|
||||
]);
|
||||
return View::make('dashboard.components.groups.edit')
|
||||
->withPageTitle(trans('dashboard.components.groups.edit.title').' - '.trans('dashboard.dashboard'))
|
||||
->withGroup($group);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,25 +243,17 @@ class ComponentController extends AbstractController
|
||||
*/
|
||||
public function postAddComponentGroup()
|
||||
{
|
||||
$group = ComponentGroup::create(Binput::get('group'));
|
||||
|
||||
if (!$group->isValid()) {
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.components.groups.add.failure')
|
||||
))
|
||||
->with('errors', $group->getErrors());
|
||||
try {
|
||||
$group = ComponentGroup::create(Binput::get('group'));
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::all())
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.add.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.components.groups.add.success')
|
||||
);
|
||||
|
||||
return Redirect::back()->with('success', $successMsg);
|
||||
return Redirect::back()
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.add.success')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,24 +266,17 @@ class ComponentController extends AbstractController
|
||||
public function updateComponentGroupAction(ComponentGroup $group)
|
||||
{
|
||||
$groupData = Binput::get('group');
|
||||
$group->update($groupData);
|
||||
|
||||
if (!$group->isValid()) {
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.components.groups.edit.failure')
|
||||
))
|
||||
->with('errors', $group->getErrors());
|
||||
try {
|
||||
$group->update($groupData);
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::all())
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.groups.edit.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.components.groups.edit.success')
|
||||
);
|
||||
|
||||
return Redirect::back()->with('success', $successMsg);
|
||||
return Redirect::back()
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.groups.edit.success')));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +26,8 @@ class DashboardController extends AbstractController
|
||||
{
|
||||
$components = Component::orderBy('order')->get();
|
||||
|
||||
return View::make('dashboard.index')->with([
|
||||
'components' => $components,
|
||||
]);
|
||||
return View::make('dashboard.index')
|
||||
->withComponents($components);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,8 +37,7 @@ class DashboardController extends AbstractController
|
||||
*/
|
||||
public function showNotifications()
|
||||
{
|
||||
return View::make('dashboard.notifications.index')->with([
|
||||
'page_title' => trans('dashboard.notifications.notifications').' '.trans('dashboard.dashboard'),
|
||||
]);
|
||||
return View::make('dashboard.notifications.index')
|
||||
->withPageTitle(trans('dashboard.notifications.notifications').' '.trans('dashboard.dashboard'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Admin;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Events\IncidentHasReportedEvent;
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Cachet\Http\Controllers\AbstractController;
|
||||
@@ -68,10 +69,9 @@ class IncidentController extends AbstractController
|
||||
{
|
||||
$incidents = Incident::notScheduled()->orderBy('created_at', 'desc')->get();
|
||||
|
||||
return View::make('dashboard.incidents.index')->with([
|
||||
'page_title' => trans('dashboard.incidents.incidents').' - '.trans('dashboard.dashboard'),
|
||||
'incidents' => $incidents,
|
||||
]);
|
||||
return View::make('dashboard.incidents.index')
|
||||
->withPageTitle(trans('dashboard.incidents.incidents').' - '.trans('dashboard.dashboard'))
|
||||
->withIncidents($incidents);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,15 +81,11 @@ class IncidentController extends AbstractController
|
||||
*/
|
||||
public function showAddIncident()
|
||||
{
|
||||
$componentsInGroups = ComponentGroup::with('components')->get();
|
||||
$componentsOutGroups = Component::where('group_id', 0)->get();
|
||||
|
||||
return View::make('dashboard.incidents.add')->with([
|
||||
'page_title' => trans('dashboard.incidents.add.title').' - '.trans('dashboard.dashboard'),
|
||||
'componentsInGroups' => $componentsInGroups,
|
||||
'componentsOutGroups' => $componentsOutGroups,
|
||||
'incidentTemplates' => IncidentTemplate::all(),
|
||||
]);
|
||||
return View::make('dashboard.incidents.add')
|
||||
->withPageTitle(trans('dashboard.incidents.add.title').' - '.trans('dashboard.dashboard'))
|
||||
->withComponentsInGroups(ComponentGroup::with('components')->get())
|
||||
->withComponentsOutGroups(Component::where('group_id', 0)->get())
|
||||
->withIncidentTemplates(IncidentTemplate::all());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,10 +95,9 @@ class IncidentController extends AbstractController
|
||||
*/
|
||||
public function showTemplates()
|
||||
{
|
||||
return View::make('dashboard.incidents.templates.index')->with([
|
||||
'page_title' => trans('dashboard.incidents.templates.title').' - '.trans('dashboard.dashboard'),
|
||||
'incidentTemplates' => IncidentTemplate::all(),
|
||||
]);
|
||||
return View::make('dashboard.incidents.templates.index')
|
||||
->withPageTitle(trans('dashboard.incidents.templates.title').' - '.trans('dashboard.dashboard'))
|
||||
->withIncidentTemplates(IncidentTemplate::all());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,41 +118,26 @@ class IncidentController extends AbstractController
|
||||
unset($incidentData['created_at']);
|
||||
}
|
||||
|
||||
$incident = Incident::create($incidentData);
|
||||
|
||||
if (!$incident->isValid()) {
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.incidents.add.failure')
|
||||
))
|
||||
->with('errors', $incident->getErrors());
|
||||
try {
|
||||
$incident = Incident::create($incidentData);
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::all())
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.add.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
// Update the component.
|
||||
if (isset($incidentData['component_id']) && (int) $incidentData['component_id'] > 0) {
|
||||
Component::find($incidentData['component_id'])->update([
|
||||
'status' => $componentStatus,
|
||||
]);
|
||||
Component::find($incidentData['component_id'])->update(['status' => $componentStatus]);
|
||||
}
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.incidents.add.success')
|
||||
);
|
||||
|
||||
$isEnabled = (bool) Setting::get('enable_subscribers', false);
|
||||
$mailAddress = env('MAIL_ADDRESS', false);
|
||||
$mailFrom = env('MAIL_NAME', false);
|
||||
$subscribersEnabled = $isEnabled && $mailAddress && $mailFrom;
|
||||
|
||||
if (array_get($incidentData, 'notify') && $subscribersEnabled) {
|
||||
if (array_get($incidentData, 'notify') && subscribers_enabled()) {
|
||||
event(new IncidentHasReportedEvent($incident));
|
||||
}
|
||||
|
||||
return Redirect::back()->with('success', $successMsg);
|
||||
return Redirect::back()
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.add.success')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,9 +147,8 @@ class IncidentController extends AbstractController
|
||||
*/
|
||||
public function showAddIncidentTemplate()
|
||||
{
|
||||
return View::make('dashboard.incidents.templates.add')->with([
|
||||
'page_title' => trans('dashboard.incidents.templates.add.title').' - '.trans('dashboard.dashboard'),
|
||||
]);
|
||||
return View::make('dashboard.incidents.templates.add')
|
||||
->withPageTitle(trans('dashboard.incidents.templates.add.title').' - '.trans('dashboard.dashboard'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,10 +160,9 @@ class IncidentController extends AbstractController
|
||||
*/
|
||||
public function showEditTemplateAction(IncidentTemplate $template)
|
||||
{
|
||||
return View::make('dashboard.incidents.templates.edit')->with([
|
||||
'page_title' => trans('dashboard.incidents.templates.edit.title').' - '.trans('dashboard.dashboard'),
|
||||
'template' => $template,
|
||||
]);
|
||||
return View::make('dashboard.incidents.templates.edit')
|
||||
->withPageTitle(trans('dashboard.incidents.templates.edit.title').' - '.trans('dashboard.dashboard'))
|
||||
->withTemplate($template);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,26 +186,17 @@ class IncidentController extends AbstractController
|
||||
*/
|
||||
public function createIncidentTemplateAction()
|
||||
{
|
||||
$_template = Binput::get('template');
|
||||
$template = IncidentTemplate::create($_template);
|
||||
|
||||
if (!$template->isValid()) {
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.incidents.templates.add.failure')
|
||||
))
|
||||
->with('errors', $template->getErrors());
|
||||
try {
|
||||
IncidentTemplate::create(Binput::get('template'));
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::all())
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.add.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.incidents.templates.add.success')
|
||||
);
|
||||
|
||||
return Redirect::back()->with('success', $successMsg);
|
||||
return Redirect::back()
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.add.success')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,15 +222,11 @@ class IncidentController extends AbstractController
|
||||
*/
|
||||
public function showEditIncidentAction(Incident $incident)
|
||||
{
|
||||
$componentsInGroups = ComponentGroup::with('components')->get();
|
||||
$componentsOutGroups = Component::where('group_id', 0)->get();
|
||||
|
||||
return View::make('dashboard.incidents.edit')->with([
|
||||
'page_title' => trans('dashboard.incidents.edit.title').' - '.trans('dashboard.dashboard'),
|
||||
'incident' => $incident,
|
||||
'componentsInGroups' => $componentsInGroups,
|
||||
'componentsOutGroups' => $componentsOutGroups,
|
||||
]);
|
||||
return View::make('dashboard.incidents.edit')
|
||||
->withPageTitle(trans('dashboard.incidents.edit.title').' - '.trans('dashboard.dashboard'))
|
||||
->withIncident($incident)
|
||||
->withComponentsInGroups(ComponentGroup::with('components')->get())
|
||||
->withComponentsOutGroups(Component::where('group_id', 0)->get());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,32 +248,23 @@ class IncidentController extends AbstractController
|
||||
unset($incidentData['created_at']);
|
||||
}
|
||||
|
||||
$incident->update($incidentData);
|
||||
|
||||
if (!$incident->isValid()) {
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.incidents.templates.edit.failure')
|
||||
))
|
||||
->with('errors', $incident->getErrors());
|
||||
try {
|
||||
$incident->update($incidentData);
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::all())
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
$componentStatus = array_pull($incidentData, 'component_status');
|
||||
|
||||
if ($incident->component) {
|
||||
$incident->component->update([
|
||||
'status' => $componentStatus,
|
||||
]);
|
||||
$incident->component->update(['status' => $componentStatus]);
|
||||
}
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.incidents.edit.success')
|
||||
);
|
||||
|
||||
return Redirect::to('dashboard/incidents')->with('success', $successMsg);
|
||||
return Redirect::to('dashboard/incidents')
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.edit.success')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,8 +276,15 @@ class IncidentController extends AbstractController
|
||||
*/
|
||||
public function editTemplateAction(IncidentTemplate $template)
|
||||
{
|
||||
$template->update(Binput::get('template'));
|
||||
try {
|
||||
$template->update(Binput::get('template'));
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withUpdatedTemplate($template)
|
||||
->withTemplateErrors($e->getMessageBag()->getErrors());
|
||||
}
|
||||
|
||||
return Redirect::back()->with('updatedTemplate', $template);
|
||||
return Redirect::back()
|
||||
->withUpdatedTemplate($template);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Admin;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Http\Controllers\AbstractController;
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
use CachetHQ\Cachet\Models\MetricPoint;
|
||||
@@ -29,10 +30,9 @@ class MetricController extends AbstractController
|
||||
{
|
||||
$metrics = Metric::orderBy('created_at', 'desc')->get();
|
||||
|
||||
return View::make('dashboard.metrics.index')->with([
|
||||
'page_title' => trans('dashboard.metrics.metrics').' - '.trans('dashboard.dashboard'),
|
||||
'metrics' => $metrics,
|
||||
]);
|
||||
return View::make('dashboard.metrics.index')
|
||||
->withPageTitle(trans('dashboard.metrics.metrics').' - '.trans('dashboard.dashboard'))
|
||||
->withMetrics($metrics);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,10 +42,8 @@ class MetricController extends AbstractController
|
||||
*/
|
||||
public function showAddMetric()
|
||||
{
|
||||
return View::make('dashboard.metrics.add')->with([
|
||||
'page_title' => trans('dashboard.metrics.add.title').' - '.trans('dashboard.dashboard'),
|
||||
'metricMetricPoints' => MetricPoint::all(),
|
||||
]);
|
||||
return View::make('dashboard.metrics.add')
|
||||
->withPageTitle(trans('dashboard.metrics.add.title').' - '.trans('dashboard.dashboard'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,10 +53,9 @@ class MetricController extends AbstractController
|
||||
*/
|
||||
public function showMetricPoints()
|
||||
{
|
||||
return View::make('dashboard.metrics.points.index')->with([
|
||||
'page_title' => trans('dashboard.metrics.points.title').' - '.trans('dashboard.dashboard'),
|
||||
'metricMetricPoints' => MetricPoint::all(),
|
||||
]);
|
||||
return View::make('dashboard.metrics.points.index')
|
||||
->withPageTitle(trans('dashboard.metrics.points.title').' - '.trans('dashboard.dashboard'))
|
||||
->withMetrics(MetricPoint::all());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,26 +65,17 @@ class MetricController extends AbstractController
|
||||
*/
|
||||
public function createMetricAction()
|
||||
{
|
||||
$metricData = Binput::get('metric');
|
||||
$metric = Metric::create($metricData);
|
||||
|
||||
if (!$metric->isValid()) {
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.metrics.add.failure')
|
||||
))
|
||||
->with('errors', $metric->getErrors());
|
||||
try {
|
||||
Metric::create(Binput::get('metric'));
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::all())
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.metrics.add.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.metrics.add.success')
|
||||
);
|
||||
|
||||
return Redirect::back()->with('success', $successMsg);
|
||||
return Redirect::back()
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.add.success')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,9 +85,8 @@ class MetricController extends AbstractController
|
||||
*/
|
||||
public function showAddMetricPoint()
|
||||
{
|
||||
return View::make('dashboard.metrics.points.add')->with([
|
||||
'page_title' => trans('dashboard.metrics.points.add.title').' - '.trans('dashboard.dashboard'),
|
||||
]);
|
||||
return View::make('dashboard.metrics.points.add')
|
||||
->withPageTitle(trans('dashboard.metrics.points.add.title').' - '.trans('dashboard.dashboard'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,26 +96,17 @@ class MetricController extends AbstractController
|
||||
*/
|
||||
public function createMetricPointAction()
|
||||
{
|
||||
$_point = Binput::get('point', null, false);
|
||||
$point = MetricPoint::create($_point);
|
||||
|
||||
if (!$point->isValid()) {
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.metrics.points.add.failure')
|
||||
))
|
||||
->with('errors', $point->getErrors());
|
||||
try {
|
||||
MetricPoint::create(Binput::get('point', null, false));
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::all())
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.metrics.points.add.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.metrics.points.add.success')
|
||||
);
|
||||
|
||||
return Redirect::back()->with('success', $successMsg);
|
||||
return Redirect::back()
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.points.add.success')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,10 +132,9 @@ class MetricController extends AbstractController
|
||||
*/
|
||||
public function showEditMetricAction(Metric $metric)
|
||||
{
|
||||
return View::make('dashboard.metrics.edit')->with([
|
||||
'page_title' => trans('dashboard.metrics.edit.title').' - '.trans('dashboard.dashboard'),
|
||||
'metric' => $metric,
|
||||
]);
|
||||
return View::make('dashboard.metrics.edit')
|
||||
->withPageTitle(trans('dashboard.metrics.edit.title').' - '.trans('dashboard.dashboard'))
|
||||
->withMetric($metric);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,24 +146,16 @@ class MetricController extends AbstractController
|
||||
*/
|
||||
public function editMetricAction(Metric $metric)
|
||||
{
|
||||
$metricData = Binput::get('metric', null, false);
|
||||
$metric->update($metricData);
|
||||
|
||||
if (!$metric->isValid()) {
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'<strong>%s</strong>',
|
||||
trans('dashboard.notifications.whoops')
|
||||
))
|
||||
->with('errors', $metric->getErrors());
|
||||
try {
|
||||
$metric->update(Binput::get('metric', null, false));
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::all())
|
||||
->withTitle(sprintf('<strong>%s</strong>', trans('dashboard.notifications.whoops')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.metrics.edit.success')
|
||||
);
|
||||
|
||||
return Redirect::to('dashboard/metrics')->with('success', $successMsg);
|
||||
return Redirect::to('dashboard/metrics')
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.metrics.edit.success')));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Admin;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Events\MaintenanceHasScheduledEvent;
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Cachet\Http\Controllers\AbstractController;
|
||||
@@ -80,9 +81,8 @@ class ScheduleController extends AbstractController
|
||||
{
|
||||
$incidentTemplates = IncidentTemplate::all();
|
||||
|
||||
return View::make('dashboard.schedule.add')->with([
|
||||
'incidentTemplates' => $incidentTemplates,
|
||||
]);
|
||||
return View::make('dashboard.schedule.add')
|
||||
->withIncidentTemplates($incidentTemplates);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,9 +99,7 @@ class ScheduleController extends AbstractController
|
||||
|
||||
if ($scheduledAt->isPast()) {
|
||||
$messageBag = new MessageBag();
|
||||
$messageBag->add('scheduled_at', trans('validation.date', [
|
||||
'attribute' => 'scheduled time you supplied',
|
||||
]));
|
||||
$messageBag->add('scheduled_at', trans('validation.date', ['attribute' => 'scheduled time you supplied']));
|
||||
|
||||
return Redirect::back()->withErrors($messageBag);
|
||||
}
|
||||
@@ -110,34 +108,21 @@ class ScheduleController extends AbstractController
|
||||
// Bypass the incident.status field.
|
||||
$scheduleData['status'] = 0;
|
||||
|
||||
$incident = Incident::create($scheduleData);
|
||||
|
||||
if (!$incident->isValid()) {
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('success', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.schedule.add.failure')
|
||||
))
|
||||
->with('errors', $incident->getErrors());
|
||||
try {
|
||||
Incident::create($scheduleData);
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::all())
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.add.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.schedule.add.success')
|
||||
);
|
||||
|
||||
$isEnabled = (bool) Setting::get('enable_subscribers', false);
|
||||
$mailAddress = env('MAIL_ADDRESS', false);
|
||||
$mailFrom = env('MAIL_NAME', false);
|
||||
$subscribersEnabled = $isEnabled && $mailAddress && $mailFrom;
|
||||
|
||||
if (array_get($scheduleData, 'notify') && $subscribersEnabled) {
|
||||
if (array_get($scheduleData, 'notify') && subscribers_enabled()) {
|
||||
event(new MaintenanceHasScheduledEvent($incident));
|
||||
}
|
||||
|
||||
return Redirect::back()->with('success', $successMsg);
|
||||
return Redirect::back()
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.add.success')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,10 +136,9 @@ class ScheduleController extends AbstractController
|
||||
{
|
||||
$incidentTemplates = IncidentTemplate::all();
|
||||
|
||||
return View::make('dashboard.schedule.edit')->with([
|
||||
'incidentTemplates' => $incidentTemplates,
|
||||
'schedule' => $schedule,
|
||||
]);
|
||||
return View::make('dashboard.schedule.edit')
|
||||
->withIncidentTemplates($incidentTemplates)
|
||||
->withSchedule($schedule);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,9 +157,7 @@ class ScheduleController extends AbstractController
|
||||
|
||||
if ($scheduledAt->isPast()) {
|
||||
$messageBag = new MessageBag();
|
||||
$messageBag->add('scheduled_at', trans('validation.date', [
|
||||
'attribute' => 'scheduled time you supplied',
|
||||
]));
|
||||
$messageBag->add('scheduled_at', trans('validation.date', ['attribute' => 'scheduled time you supplied']));
|
||||
|
||||
return Redirect::back()->withErrors($messageBag);
|
||||
}
|
||||
@@ -184,25 +166,17 @@ class ScheduleController extends AbstractController
|
||||
// Bypass the incident.status field.
|
||||
$scheduleData['status'] = 0;
|
||||
|
||||
$schedule->update($scheduleData);
|
||||
|
||||
if (!$schedule->isValid()) {
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.schedule.edit.failure')
|
||||
))
|
||||
->with('errors', $schedule->getErrors());
|
||||
try {
|
||||
$schedule->update($scheduleData);
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::all())
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.edit.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.schedule.edit.success')
|
||||
);
|
||||
|
||||
return Redirect::to('dashboard/schedule')->with('success', $successMsg);
|
||||
return Redirect::to('dashboard/schedule')
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.edit.success')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,10 +190,7 @@ class ScheduleController extends AbstractController
|
||||
{
|
||||
$schedule->delete();
|
||||
|
||||
return Redirect::back()->with('warning', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.schedule.delete.failure')
|
||||
));
|
||||
return Redirect::back()
|
||||
->withWarning(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.delete.failure')));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,10 +68,9 @@ class SettingsController extends AbstractController
|
||||
{
|
||||
$this->subMenu['setup']['active'] = true;
|
||||
|
||||
return View::make('dashboard.settings.app-setup')->with([
|
||||
'page_title' => 'Application Setup - Dashboard',
|
||||
'sub_menu' => $this->subMenu,
|
||||
]);
|
||||
return View::make('dashboard.settings.app-setup')
|
||||
->withPageTitle('Application Setup - Dashboard')
|
||||
->withSubMenu($this->subMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,10 +82,9 @@ class SettingsController extends AbstractController
|
||||
{
|
||||
$this->subMenu['theme']['active'] = true;
|
||||
|
||||
return View::make('dashboard.settings.theme')->with([
|
||||
'page_title' => 'Theme - Dashboard',
|
||||
'sub_menu' => $this->subMenu,
|
||||
]);
|
||||
return View::make('dashboard.settings.theme')
|
||||
->withPageTitle('Theme - Dashboard')
|
||||
->withSubMenu($this->subMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,11 +98,10 @@ class SettingsController extends AbstractController
|
||||
|
||||
$unsecureUsers = User::whereNull('google_2fa_secret')->orWhere('google_2fa_secret', '')->get();
|
||||
|
||||
return View::make('dashboard.settings.security')->with([
|
||||
'page_title' => 'Security - Dashboard',
|
||||
'sub_menu' => $this->subMenu,
|
||||
'unsecureUsers' => $unsecureUsers,
|
||||
]);
|
||||
return View::make('dashboard.settings.security')
|
||||
->withPageTitle('Security - Dashboard')
|
||||
->withSubMenu($this->subMenu)
|
||||
->withUnsecureUsers($unsecureUsers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,10 +113,9 @@ class SettingsController extends AbstractController
|
||||
{
|
||||
$this->subMenu['stylesheet']['active'] = true;
|
||||
|
||||
return View::make('dashboard.settings.stylesheet')->with([
|
||||
'page_title' => 'Stylesheet - Dashboard',
|
||||
'sub_menu' => $this->subMenu,
|
||||
]);
|
||||
return View::make('dashboard.settings.stylesheet')
|
||||
->withPageTitle('Stylesheet - Dashboard')
|
||||
->withSubMenu($this->subMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,9 +138,7 @@ class SettingsController extends AbstractController
|
||||
$maxSize = $file->getMaxFilesize();
|
||||
|
||||
if ($file->getSize() > $maxSize) {
|
||||
return Redirect::back()->withErrors(trans('dashboard.settings.app-setup.too-big', [
|
||||
'size' => $maxSize,
|
||||
]));
|
||||
return Redirect::back()->withErrors(trans('dashboard.settings.app-setup.too-big', ['size' => $maxSize]));
|
||||
}
|
||||
|
||||
if (!$file->isValid() || $file->getError()) {
|
||||
@@ -156,18 +150,10 @@ class SettingsController extends AbstractController
|
||||
}
|
||||
|
||||
// Store the banner.
|
||||
Setting::firstOrCreate([
|
||||
'name' => 'app_banner',
|
||||
])->update([
|
||||
'value' => base64_encode(file_get_contents($file->getRealPath())),
|
||||
]);
|
||||
Setting::firstOrCreate(['name' => 'app_banner'])->update(['value' => base64_encode(file_get_contents($file->getRealPath()))]);
|
||||
|
||||
// Store the banner type
|
||||
Setting::firstOrCreate([
|
||||
'name' => 'app_banner_type',
|
||||
])->update([
|
||||
'value' => $file->getMimeType(),
|
||||
]);
|
||||
Setting::firstOrCreate(['name' => 'app_banner_type'])->update(['value' => $file->getMimeType()]);
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -176,18 +162,15 @@ class SettingsController extends AbstractController
|
||||
$settingValue = rtrim($settingValue, '/');
|
||||
}
|
||||
|
||||
Setting::firstOrCreate([
|
||||
'name' => $settingName,
|
||||
])->update([
|
||||
'value' => $settingValue,
|
||||
]);
|
||||
Setting::firstOrCreate(['name' => $settingName])->update(['value' => $settingValue]);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return Redirect::back()->with('errors', trans('dashboard.settings.edit.failure'));
|
||||
return Redirect::back()->withErrors(trans('dashboard.settings.edit.failure'));
|
||||
}
|
||||
|
||||
Lang::setLocale(Binput::get('app_locale'));
|
||||
|
||||
return Redirect::back()->with('success', trans('dashboard.settings.edit.success'));
|
||||
return Redirect::back()
|
||||
->withSuccess(trans('dashboard.settings.edit.success'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Admin;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Events\CustomerHasSubscribedEvent;
|
||||
use CachetHQ\Cachet\Http\Controllers\AbstractController;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
@@ -30,10 +31,8 @@ class SubscriberController extends AbstractController
|
||||
$subscribers = Subscriber::all();
|
||||
|
||||
return View::make('dashboard.subscribers.index')
|
||||
->with([
|
||||
'page_title' => trans('dashboard.subscribers.subscribers').' - '.trans('dashboard.dashboard'),
|
||||
'subscribers' => $subscribers,
|
||||
]);
|
||||
->withPageTitle(trans('dashboard.subscribers.subscribers').' - '.trans('dashboard.dashboard'))
|
||||
->withSubscribers(Subscriber::all());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,10 +43,7 @@ class SubscriberController extends AbstractController
|
||||
public function showAddSubscriber()
|
||||
{
|
||||
return View::make('dashboard.subscribers.add')
|
||||
->with([
|
||||
'page_title' => trans('dashboard.subscribers.add.title').' - '.trans('dashboard.dashboard'),
|
||||
'incidentTemplates' => Subscriber::all(),
|
||||
]);
|
||||
->withPageTitle(trans('dashboard.subscribers.add.title').' - '.trans('dashboard.dashboard'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,31 +55,19 @@ class SubscriberController extends AbstractController
|
||||
{
|
||||
$email = Binput::get('email');
|
||||
|
||||
$subscriber = Subscriber::create([
|
||||
'email' => $email,
|
||||
]);
|
||||
|
||||
if (!$subscriber->isValid()) {
|
||||
try {
|
||||
$subscriber = Subscriber::create(['email' => $email]);
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.subscribers.add.failure')
|
||||
))
|
||||
->with('errors', $subscriber->getErrors());
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.subscribers.add.success')
|
||||
);
|
||||
|
||||
event(new CustomerHasSubscribedEvent($subscriber));
|
||||
|
||||
return Redirect::back()
|
||||
->with('success', $successMsg);
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Admin;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Http\Controllers\AbstractController;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
@@ -28,10 +29,9 @@ class TeamController extends AbstractController
|
||||
{
|
||||
$team = User::all();
|
||||
|
||||
return View::make('dashboard.team.index')->with([
|
||||
'page_title' => trans('dashboard.team.team').' - '.trans('dashboard.dashboard'),
|
||||
'teamMembers' => $team,
|
||||
]);
|
||||
return View::make('dashboard.team.index')
|
||||
->withPageTitle(trans('dashboard.team.team').' - '.trans('dashboard.dashboard'))
|
||||
->withTeamMembers($team);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,10 +41,9 @@ class TeamController extends AbstractController
|
||||
*/
|
||||
public function showTeamMemberView(User $user)
|
||||
{
|
||||
return View::make('dashboard.team.edit')->with([
|
||||
'page_title' => trans('dashboard.team.edit.title').' - '.trans('dashboard.dashboard'),
|
||||
'user' => $user,
|
||||
]);
|
||||
return View::make('dashboard.team.edit')
|
||||
->withPageTitle(trans('dashboard.team.edit.title').' - '.trans('dashboard.dashboard'))
|
||||
->withUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,9 +53,8 @@ class TeamController extends AbstractController
|
||||
*/
|
||||
public function showAddTeamMemberView()
|
||||
{
|
||||
return View::make('dashboard.team.add')->with([
|
||||
'page_title' => trans('dashboard.team.add.title').' - '.trans('dashboard.dashboard'),
|
||||
]);
|
||||
return View::make('dashboard.team.add')
|
||||
->withPageTitle(trans('dashboard.team.add.title').' - '.trans('dashboard.dashboard'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,25 +64,17 @@ class TeamController extends AbstractController
|
||||
*/
|
||||
public function postAddUser()
|
||||
{
|
||||
$user = User::create(Binput::all());
|
||||
|
||||
if (!$user->isValid()) {
|
||||
return Redirect::back()->withInput(Binput::except('password'))
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.team.add.failure')
|
||||
))
|
||||
->with('errors', $user->getErrors());
|
||||
try {
|
||||
User::create(Binput::all());
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::except('password'))
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.add.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.team.add.success')
|
||||
);
|
||||
|
||||
return Redirect::back()->with('success', $successMsg);
|
||||
return Redirect::back()
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.add.success')));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,24 +94,16 @@ class TeamController extends AbstractController
|
||||
unset($items['password']);
|
||||
}
|
||||
|
||||
$user->update($items);
|
||||
|
||||
if (!$user->isValid()) {
|
||||
return Redirect::back()->withInput(Binput::except('password'))
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.team.edit.failure')
|
||||
))
|
||||
->with('errors', $user->getErrors());
|
||||
try {
|
||||
$user->update($items);
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::except('password'))
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.team.edit.success')
|
||||
);
|
||||
|
||||
return Redirect::back()->with('success', $successMsg);
|
||||
return Redirect::back()
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success')));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Admin;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Http\Controllers\AbstractController;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
@@ -28,9 +29,8 @@ class UserController extends AbstractController
|
||||
*/
|
||||
public function showUser()
|
||||
{
|
||||
return View::make('dashboard.user.index')->with([
|
||||
'page_title' => trans('dashboard.team.profile').' - '.trans('dashboard.dashboard'),
|
||||
]);
|
||||
return View::make('dashboard.user.index')
|
||||
->withPageTitle(trans('dashboard.team.profile').' - '.trans('dashboard.dashboard'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,26 +56,17 @@ class UserController extends AbstractController
|
||||
unset($items['password']);
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
$user->update($items);
|
||||
|
||||
if (!$user->isValid()) {
|
||||
return Redirect::back()->withInput(Binput::except('password'))
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.whoops'),
|
||||
trans('dashboard.team.edit.failure')
|
||||
))
|
||||
->with('errors', $user->getErrors());
|
||||
try {
|
||||
Auth::user()->update($items);
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::except('password'))
|
||||
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure')))
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.team.edit.success')
|
||||
);
|
||||
|
||||
return Redirect::back()->with('success', $successMsg);
|
||||
return Redirect::back()
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user