Refactor validator stuff and fix variable names in views

This commit is contained in:
Graham Campbell
2015-08-03 22:32:36 +01:00
parent 5d958bac81
commit fcbbfdd84e
56 changed files with 514 additions and 766 deletions

View File

@@ -14,7 +14,7 @@ namespace CachetHQ\Cachet\Composers;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Auth;
class LoggedUserComposer
class CurrentUserComposer
{
/**
* Bind data to the view.
@@ -23,6 +23,6 @@ class LoggedUserComposer
*/
public function compose(View $view)
{
$view->with('loggedUser', Auth::user());
$view->withCurrentUser(Auth::user());
}
}

View File

@@ -24,7 +24,7 @@ class DashboardComposer
*/
public function compose(View $view)
{
$view->with('incidentCount', Incident::notScheduled()->count());
$view->with('componentCount', Component::all()->count());
$view->withIncidentCount(Incident::notScheduled()->count());
$view->withComponentCount(Component::all()->count());
}
}

View File

@@ -23,8 +23,8 @@ class ThemeComposer
*/
public function compose(View $view)
{
$view->with('themeBackgroundColor', Setting::get('style_background_color'));
$view->with('themeTextColor', Setting::get('style_text_color'));
$view->withThemeBackgroundColor(Setting::get('style_background_color'));
$view->withThemeTextColor(Setting::get('style_text_color'));
$viewData = $view->getData();
$themeView = array_only($viewData, preg_grep('/^theme/', array_keys($viewData)));
@@ -32,6 +32,6 @@ class ThemeComposer
return $data != null;
});
$view->with('themeSetup', !empty($hasThemeSettings));
$view->withThemeSetup(!empty($hasThemeSettings));
}
}

View File

@@ -65,9 +65,7 @@ class TimezoneLocaleComposer
}
}
$view->with([
'timezones' => $timezones,
'langs' => $langs,
]);
$view->withTimezones($timezones);
$view->withLangs($langs);
}
}

View File

@@ -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.");
}
}

View File

@@ -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')));
}
}

View File

@@ -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'));
}
}

View File

@@ -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);
}
}

View File

@@ -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')));
}
}

View File

@@ -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')));
}
}

View File

@@ -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'));
}
}

View File

@@ -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')));
}
/**

View File

@@ -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')));
}
}

View File

@@ -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')));
}
/**

View File

@@ -64,10 +64,6 @@ class ComponentController extends AbstractApiController
throw new BadRequestHttpException();
}
if (!$component->isValid()) {
throw new BadRequestHttpException();
}
if (Binput::has('tags')) {
// The component was added successfully, so now let's deal with the tags.
$tags = preg_split('/ ?, ?/', Binput::get('tags'));
@@ -94,9 +90,9 @@ class ComponentController extends AbstractApiController
*/
public function putComponent(Component $component)
{
$component->update(Binput::except('tags'));
if (!$component->isValid('updating')) {
try {
$component->update(Binput::except('tags'));
} catch (Exception $e) {
throw new BadRequestHttpException();
}
@@ -105,9 +101,7 @@ class ComponentController extends AbstractApiController
// 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);

View File

@@ -12,7 +12,6 @@
namespace CachetHQ\Cachet\Http\Controllers\Api;
use CachetHQ\Cachet\Events\IncidentHasReportedEvent;
use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Models\Incident;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
@@ -34,8 +33,7 @@ class IncidentController extends AbstractApiController
{
$incidentVisiblity = $auth->check() ? 0 : 1;
$incidents = Incident::where('visible', '>=', $incidentVisiblity)
->paginate(Binput::get('per_page', 20));
$incidents = Incident::where('visible', '>=', $incidentVisiblity)->paginate(Binput::get('per_page', 20));
return $this->paginator($incidents, $request);
}
@@ -73,20 +71,11 @@ class IncidentController extends AbstractApiController
throw new BadRequestHttpException();
}
$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));
}
if ($incident->isValid()) {
return $this->item($incident);
}
throw new BadRequestHttpException();
return $this->item($incident);
}
/**
@@ -98,13 +87,13 @@ class IncidentController extends AbstractApiController
*/
public function putIncident(Incident $incident)
{
$incident->update(Binput::all());
if ($incident->isValid('updating')) {
return $this->item($incident);
try {
$incident->update(Binput::all());
} catch (Exception $e) {
throw new BadRequestHttpException();
}
throw new BadRequestHttpException();
return $this->item($incident);
}
/**

View File

@@ -70,11 +70,7 @@ class MetricController extends AbstractApiController
throw new BadRequestHttpException();
}
if ($metric->isValid()) {
return $this->item($metric);
}
throw new BadRequestHttpException();
return $this->item($metric);
}
/**
@@ -86,13 +82,13 @@ class MetricController extends AbstractApiController
*/
public function putMetric(Metric $metric)
{
$metric->update(Binput::all());
if ($metric->isValid('updating')) {
return $this->item($metric);
try {
$metric->update(Binput::all());
} catch (Exception $e) {
throw new BadRequestHttpException();
}
throw new BadRequestHttpException();
return $this->item($metric);
}
/**

View File

@@ -49,16 +49,12 @@ class SubscriberController extends AbstractApiController
throw new BadRequestHttpException();
}
if ($subscriber->isValid()) {
// If we're auto-verifying the subscriber, don't bother with this event.
if (!(Binput::get('verify'))) {
event(new CustomerHasSubscribedEvent($subscriber));
}
return $this->item($subscriber);
// If we're auto-verifying the subscriber, don't bother with this event.
if (!(Binput::get('verify'))) {
event(new CustomerHasSubscribedEvent($subscriber));
}
throw new BadRequestHttpException();
return $this->item($subscriber);
}
/**

View File

@@ -56,6 +56,8 @@ class AtomController extends AbstractController
*
* @param \Roumen\Feed\Facades\Feed $feed
* @param \CachetHQ\Cachet\Models\Incident $incident
*
* @return void
*/
private function feedAddItem(&$feed, $incident)
{

View File

@@ -19,9 +19,6 @@ use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\View;
use PragmaRX\Google2FA\Vendor\Laravel\Facade as Google2FA;
/**
* Logs users into their account.
*/
class AuthController extends AbstractController
{
/**
@@ -31,9 +28,8 @@ class AuthController extends AbstractController
*/
public function showLogin()
{
return View::make('auth.login')->with([
'page_title' => trans('dashboard.login.login'),
]);
return View::make('auth.login')
->withPageTitle(trans('dashboard.login.login'));
}
/**
@@ -64,7 +60,7 @@ class AuthController extends AbstractController
return Redirect::back()
->withInput(Binput::except('password'))
->with('error', trans('forms.login.invalid'));
->withError(trans('forms.login.invalid'));
}
/**
@@ -101,11 +97,11 @@ class AuthController extends AbstractController
// Failed login, log back out.
Auth::logout();
return Redirect::route('login')->with('error', trans('forms.login.invalid-token'));
return Redirect::route('login')->withError(trans('forms.login.invalid-token'));
}
}
return Redirect::route('login')->with('error', trans('forms.login.invalid-token'));
return Redirect::route('login')->withError(trans('forms.login.invalid-token'));
}
/**

View File

@@ -92,21 +92,18 @@ class HomeController extends AbstractController
$componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
$ungroupedComponents = Component::where('group_id', 0)->orderBy('order')->orderBy('created_at')->get();
$canPageBackward = Incident::notScheduled()->where('created_at', '<', $startDate->format('Y-m-d'))->count() != 0;
return View::make('index', [
'componentGroups' => $componentGroups,
'ungroupedComponents' => $ungroupedComponents,
'displayMetrics' => $displayMetrics,
'metrics' => $metrics,
'allIncidents' => $allIncidents,
'scheduledMaintenance' => $scheduledMaintenance,
'aboutApp' => Markdown::convertToHtml(Setting::get('app_about')),
'canPageForward' => (bool) $today->gt($startDate),
'canPageBackward' => $canPageBackward,
'previousDate' => $startDate->copy()->subDays($daysToShow)->toDateString(),
'nextDate' => $startDate->copy()->addDays($daysToShow)->toDateString(),
'page_title' => Setting::get('app_name'),
]);
return View::make('index')
->withComponentGroups($componentGroups)
->withUngroupedComponents($ungroupedComponents)
->withDisplayMetrics($displayMetrics)
->withMetrics($metrics)
->withAllIncidents($allIncidents)
->withScheduledMaintenance($scheduledMaintenance)
->withAboutApp(Markdown::convertToHtml(Setting::get('app_about')))
->withCanPageForward((bool) $today->gt($startDate))
->withCanPageBackward(Incident::notScheduled()->where('created_at', '<', $startDate->format('Y-m-d'))->count() > 0)
->withPreviousDate($startDate->copy()->subDays($daysToShow)->toDateString())
->withNextDate($startDate->copy()->addDays($daysToShow)->toDateString())
->withPageTitle(Setting::get('app_name'));
}
}

View File

@@ -41,6 +41,8 @@ class SetupController extends AbstractController
/**
* Create a new setup controller instance.
*
* @return void
*/
public function __construct()
{
@@ -59,11 +61,10 @@ class SetupController extends AbstractController
$this->keyGenerate();
}
return View::make('setup')->with([
'page_title' => trans('setup.setup'),
'cacheDrivers' => $this->cacheDrivers,
'appUrl' => Request::root(),
]);
return View::make('setup')
->withPageTitle(trans('setup.setup'))
->withCacheDrivers($this->cacheDrivers)
->withAppUrl(Request::root());
}
/**
@@ -82,9 +83,9 @@ class SetupController extends AbstractController
if ($v->passes()) {
return Response::json(['status' => 1]);
} else {
return Response::json(['errors' => $v->messages()], 400);
}
return Response::json(['errors' => $v->getMessageBag()], 400);
}
/**
@@ -108,9 +109,9 @@ class SetupController extends AbstractController
if ($v->passes()) {
return Response::json(['status' => 1]);
} else {
return Response::json(['errors' => $v->messages()], 400);
}
return Response::json(['errors' => $v->getMessageBag()], 400);
}
/**
@@ -171,13 +172,13 @@ class SetupController extends AbstractController
}
return Redirect::to('dashboard');
} else {
if (Request::ajax()) {
return Response::json(['errors' => $v->messages()], 400);
}
return Redirect::back()->withInput()->with('errors', $v->messages());
}
if (Request::ajax()) {
return Response::json(['errors' => $v->getMessageBag()], 400);
}
return Redirect::back()->withInput()->withErrors($v->getMessageBag());
}
/**
@@ -185,6 +186,8 @@ class SetupController extends AbstractController
*
* @param string $key
* @param mixed $value
*
* @return void
*/
protected function writeEnv($key, $value)
{
@@ -200,6 +203,8 @@ class SetupController extends AbstractController
/**
* Generate the app.key value.
*
* @return void
*/
protected function keyGenerate()
{

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Http\Controllers;
use AltThree\Validator\ValidationException;
use CachetHQ\Cachet\Events\CustomerHasSubscribedEvent;
use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Models\Subscriber;
@@ -30,10 +31,9 @@ class SubscribeController extends AbstractController
*/
public function showSubscribe()
{
return View::make('subscribe', [
'page_title' => Setting::get('app_name'),
'aboutApp' => Markdown::convertToHtml(Setting::get('app_about')),
]);
return View::make('subscribe')
->withPageTitle(Setting::get('app_name'))
->withAboutApp(Markdown::convertToHtml(Setting::get('app_about')));
}
/**
@@ -43,33 +43,25 @@ class SubscribeController extends AbstractController
*/
public function postSubscribe()
{
$subscriber = Subscriber::create(['email' => Binput::get('email')]);
if (!$subscriber->isValid()) {
return Redirect::back()->withInput(Binput::all())
->with('title', sprintf(
'<strong>%s</strong> %s',
trans('dashboard.notifications.whoops'),
trans('cachet.subscriber.email.failure')
))
->with('errors', $subscriber->getErrors());
try {
$subscriber = Subscriber::create(['email' => Binput::get('email')]);
} catch (ValidationException $e) {
return Redirect::back()
->withInput(Binput::all())
->withTitle(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))
->withErrors($e->getMessageBag());
}
$successMsg = sprintf(
'<strong>%s</strong> %s',
trans('dashboard.notifications.awesome'),
trans('cachet.subscriber.email.subscribed')
);
event(new CustomerHasSubscribedEvent($subscriber));
return Redirect::route('status-page')->with('success', $successMsg);
return Redirect::route('status-page')
->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed')));
}
/**
* Handle the verify subscriber email.
*
* @param string $code
* @param string|null $code
*
* @return \Illuminate\View\View
*/
@@ -88,19 +80,14 @@ class SubscribeController extends AbstractController
$subscriber->verified_at = Carbon::now();
$subscriber->save();
$successMsg = sprintf(
'<strong>%s</strong> %s',
trans('dashboard.notifications.awesome'),
trans('cachet.subscriber.email.verified')
);
return Redirect::route('status-page')->with('success', $successMsg);
return Redirect::route('status-page')
->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.verified')));
}
/**
* Handle the unsubscribe.
*
* @param string $code
* @param string|null $code
*
* @return \Illuminate\View\View
*/
@@ -118,12 +105,7 @@ class SubscribeController extends AbstractController
$subscriber->delete();
$successMsg = sprintf(
'<strong>%s</strong> %s',
trans('dashboard.notifications.awesome'),
trans('cachet.subscriber.email.unsuscribed')
);
return Redirect::route('status-page')->with('success', $successMsg);
return Redirect::route('status-page')
->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.unsuscribed')));
}
}

View File

@@ -11,12 +11,12 @@
namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use CachetHQ\Cachet\Presenters\ComponentPresenter;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use McCool\LaravelAutoPresenter\HasPresenter;
use Watson\Validating\ValidatingTrait;
class Component extends Model implements HasPresenter
{
@@ -27,7 +27,7 @@ class Component extends Model implements HasPresenter
*
* @var string[]
*/
protected $rules = [
public $rules = [
'name' => 'required|string',
'status' => 'integer|required',
'link' => 'url',

View File

@@ -11,8 +11,8 @@
namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use Illuminate\Database\Eloquent\Model;
use Watson\Validating\ValidatingTrait;
class ComponentGroup extends Model
{
@@ -23,8 +23,8 @@ class ComponentGroup extends Model
*
* @var string[]
*/
protected $rules = [
'name' => 'required|unique:component_groups',
public $rules = [
'name' => 'required',
];
/**

View File

@@ -11,12 +11,12 @@
namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use CachetHQ\Cachet\Presenters\IncidentPresenter;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use McCool\LaravelAutoPresenter\HasPresenter;
use Watson\Validating\ValidatingTrait;
class Incident extends Model implements HasPresenter
{
@@ -27,7 +27,7 @@ class Incident extends Model implements HasPresenter
*
* @var string[]
*/
protected $rules = [
public $rules = [
'component_id' => 'integer',
'name' => 'required',
'status' => 'required|integer',

View File

@@ -11,9 +11,9 @@
namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Watson\Validating\ValidatingTrait;
class IncidentTemplate extends Model
{
@@ -24,7 +24,7 @@ class IncidentTemplate extends Model
*
* @var string[]
*/
protected $rules = [
public $rules = [
'name' => 'required',
'template' => 'required',
];

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use CachetHQ\Cachet\Facades\Setting as SettingFacade;
use CachetHQ\Cachet\Presenters\MetricPresenter;
use DateInterval;
@@ -19,7 +20,6 @@ use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Jenssegers\Date\Date;
use McCool\LaravelAutoPresenter\HasPresenter;
use Watson\Validating\ValidatingTrait;
class Metric extends Model implements HasPresenter
{
@@ -45,7 +45,7 @@ class Metric extends Model implements HasPresenter
*
* @var string[]
*/
protected $rules = [
public $rules = [
'name' => 'required',
'suffix' => 'required',
'display_chart' => 'boolean',

View File

@@ -11,10 +11,10 @@
namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use CachetHQ\Cachet\Presenters\MetricPointPresenter;
use Illuminate\Database\Eloquent\Model;
use McCool\LaravelAutoPresenter\HasPresenter;
use Watson\Validating\ValidatingTrait;
class MetricPoint extends Model implements HasPresenter
{
@@ -32,7 +32,7 @@ class MetricPoint extends Model implements HasPresenter
*
* @var string[]
*/
protected $rules = [
public $rules = [
'value' => 'numeric|required',
];

View File

@@ -11,10 +11,10 @@
namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use CachetHQ\Cachet\Presenters\SubscriberPresenter;
use Illuminate\Database\Eloquent\Model;
use McCool\LaravelAutoPresenter\HasPresenter;
use Watson\Validating\ValidatingTrait;
class Subscriber extends Model implements HasPresenter
{
@@ -25,8 +25,8 @@ class Subscriber extends Model implements HasPresenter
*
* @var string[]
*/
protected $rules = [
'email' => 'required|email|unique:subscribers',
public $rules = [
'email' => 'required|email',
];
/**

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
@@ -18,7 +19,6 @@ use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\Hash;
use Watson\Validating\ValidatingTrait;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
@@ -29,9 +29,9 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
*
* @var string[]
*/
protected $rules = [
'username' => ['required', 'regex:/\A(?!.*[:;]-\))[ -~]+\z/', 'unique:users'],
'email' => 'required|email|unique:users',
public $rules = [
'username' => ['required', 'regex:/\A(?!.*[:;]-\))[ -~]+\z/'],
'email' => 'required|email',
'password' => 'required',
];

View File

@@ -12,9 +12,9 @@
namespace CachetHQ\Cachet\Providers;
use CachetHQ\Cachet\Composers\AppComposer;
use CachetHQ\Cachet\Composers\CurrentUserComposer;
use CachetHQ\Cachet\Composers\DashboardComposer;
use CachetHQ\Cachet\Composers\IndexComposer;
use CachetHQ\Cachet\Composers\LoggedUserComposer;
use CachetHQ\Cachet\Composers\ThemeComposer;
use CachetHQ\Cachet\Composers\TimezoneLocaleComposer;
use Illuminate\Contracts\View\Factory;
@@ -30,7 +30,7 @@ class ComposerServiceProvider extends ServiceProvider
public function boot(Factory $factory)
{
$factory->composer('*', AppComposer::class);
$factory->composer('*', LoggedUserComposer::class);
$factory->composer('*', CurrentUserComposer::class);
$factory->composer(['index', 'subscribe'], IndexComposer::class);
$factory->composer(['index', 'subscribe'], ThemeComposer::class);
$factory->composer('dashboard.*', DashboardComposer::class);

View File

@@ -22,6 +22,7 @@
"php": "^5.5.9",
"laravel/framework": "~5.1.6",
"alt-three/emoji": "^1.0",
"alt-three/validator": "^1.2",
"barryvdh/laravel-cors": "^0.5",
"doctrine/dbal": "^2.5",
"fideloper/proxy": "^3.0",
@@ -33,8 +34,7 @@
"jenssegers/date": "^3.0",
"mccool/laravel-auto-presenter": "^3.1",
"pragmarx/google2fa": "^0.5",
"roumen/feed": "^2.9",
"watson/validating": "^1.0"
"roumen/feed": "^2.9"
},
"require-dev": {
"fzaninotto/faker": "^1.5",

117
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "f7d40ec10be871e505c18b6e4331322d",
"hash": "b875f1d2eed19b89b2c784345ca2d200",
"packages": [
{
"name": "alt-three/emoji",
@@ -67,6 +67,66 @@
],
"time": "2015-07-25 14:20:46"
},
{
"name": "alt-three/validator",
"version": "v1.2.0",
"source": {
"type": "git",
"url": "https://github.com/AltThree/Validator.git",
"reference": "01fc9ab865df38254d03c749f6a266529a2df392"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/AltThree/Validator/zipball/01fc9ab865df38254d03c749f6a266529a2df392",
"reference": "01fc9ab865df38254d03c749f6a266529a2df392",
"shasum": ""
},
"require": {
"illuminate/contracts": "5.1.*",
"illuminate/support": "5.1.*",
"php": ">=5.5.9",
"psr/log": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.7.6"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2-dev"
}
},
"autoload": {
"psr-4": {
"AltThree\\Validator\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "James Brooks",
"email": "james@alt-three.com"
},
{
"name": "Graham Campbell",
"email": "graham@alt-three.com"
},
{
"name": "Joseph Cohen",
"email": "joe@alt-three.com"
}
],
"description": "A Validation Wrapper For Laravel 5",
"keywords": [
"Alt Three",
"logging",
"validator"
],
"time": "2015-07-28 23:55:40"
},
{
"name": "asm89/stack-cors",
"version": "0.2.1",
@@ -3165,61 +3225,6 @@
"environment"
],
"time": "2015-05-30 15:59:26"
},
{
"name": "watson/validating",
"version": "1.0.3",
"source": {
"type": "git",
"url": "https://github.com/dwightwatson/validating.git",
"reference": "c32912f760b456c043657951683ed6c468ab83e7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dwightwatson/validating/zipball/c32912f760b456c043657951683ed6c468ab83e7",
"reference": "c32912f760b456c043657951683ed6c468ab83e7",
"shasum": ""
},
"require": {
"illuminate/contracts": "5.0.*|5.1.*",
"illuminate/database": "5.0.*|5.1.*",
"illuminate/events": "5.0.*|5.1.*",
"illuminate/support": "5.0.*|5.1.*",
"illuminate/validation": "5.0.*|5.1.*",
"php": ">=5.4.0"
},
"require-dev": {
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"Watson\\Validating\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Dwight Watson",
"email": "dwight@studiousapp.com"
}
],
"description": "Eloquent model validating trait.",
"keywords": [
"eloquent",
"laravel",
"validation"
],
"time": "2015-06-03 02:25:38"
}
],
"packages-dev": [

View File

@@ -58,7 +58,7 @@
</div>
</fieldset>
<input type="hidden" name="component[user_id]" value="{{ $component->agent_id || $loggedUser->id }}">
<input type="hidden" name="component[user_id]" value="{{ $component->agent_id || $current_user->id }}">
<input type="hidden" name="component[order]" value="{{ $component->order or 0 }}">
<div class="btn-group">

View File

@@ -17,12 +17,12 @@
<form class="form-vertical" name="IncidentForm" role="form" method="POST" autocomplete="off">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<fieldset>
@if($incidentTemplates->count() > 0)
@if($incident_templates->count() > 0)
<div class="form-group">
<label for="incident-template">{{ trans('forms.incidents.templates.template') }}</label>
<select class="form-control" name="template">
<option selected></option>
@foreach($incidentTemplates as $tpl)
@foreach($incident_templates as $tpl)
<option value="{{ $tpl->slug }}">{{ $tpl->name }}</option>
@endforeach
</select>
@@ -62,19 +62,19 @@
<option value='0'>{{ trans('forms.incidents.logged_in_only') }}</option>
</select>
</div>
@if(!$componentsInGroups->isEmpty() || !$componentsOutGroups->isEmpty())
@if(!$components_in_groups->isEmpty() || !$components_out_groups->isEmpty())
<div class="form-group">
<label>{{ trans('forms.incidents.component') }}</label>
<select name='incident[component_id]' class='form-control'>
<option value='0' selected></option>
@foreach($componentsInGroups as $group)
@foreach($components_in_groups as $group)
<optgroup label="{{ $group->name }}">
@foreach($group->components as $component)
<option value='{{ $component->id }}'>{{ $component->name }}</option>
@endforeach
</optgroup>
@endforeach
@foreach($componentsOutGroups as $component)
@foreach($components_out_groups as $component)
<option value='{{ $component->id }}'>{{ $component->name }}</option>
@endforeach
</select>

View File

@@ -13,12 +13,12 @@
<div class="content-wrapper">
<div class="row">
<div class="col-md-12">
@if($updatedTemplate = Session::get('updatedTemplate'))
<div class="alert alert-{{ $updatedTemplate->isValid() ? 'success' : 'danger' }}">
@if($updatedTemplate->isValid())
{{ sprintf("%s - %s", trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.edit.success')) }}
@if($updated_template = Session::get('updated_template'))
<div class="alert alert-{{ ($template_errors = Session::get('template_errors')) ? 'danger' : 'success' }}">
@if($template_errors)
{{ sprintf("%s - %s", trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure').' '.$template_errors) }}
@else
{{ sprintf("%s - %s", trans('dashboard.notifications.whoops'), trans('dashboard.incidents.templates.edit.failure').' '.$updatedTemplate->getErrors()) }}
{{ sprintf("%s - %s", trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.edit.success')) }}
@endif
</div>
@endif

View File

@@ -16,7 +16,7 @@
<div class="row">
<div class="col-sm-12">
<div class="striped-list">
@foreach($incidentTemplates as $template)
@foreach($incident_templates as $template)
<div class="row striped-list-item">
<div class="col-xs-6">
<strong>{{ $template->name }}</strong>

View File

@@ -18,12 +18,12 @@
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="hidden" name="incident[visible]" value="1">
<fieldset>
@if($incidentTemplates->count() > 0)
@if($incident_templates->count() > 0)
<div class="form-group">
<label for="incident-template">{{ trans('forms.incidents.templates.template') }}</label>
<select class="form-control" name="template">
<option selected></option>
@foreach($incidentTemplates as $tpl)
@foreach($incident_templates as $tpl)
<option value="{{ $tpl->slug }}">{{ $tpl->name }}</option>
@endforeach
</select>

View File

@@ -18,12 +18,12 @@
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="hidden" name="incident[visible]" value="1">
<fieldset>
@if($incidentTemplates->count() > 0)
@if($incident_templates->count() > 0)
<div class="form-group">
<label for="incident-template">{{ trans('forms.incidents.templates.template') }}</label>
<select class="form-control" name="template">
<option selected></option>
@foreach($incidentTemplates as $tpl)
@foreach($incident_templates as $tpl)
<option value="{{ $tpl->slug }}">{{ $tpl->name }}</option>
@endforeach
</select>

View File

@@ -38,13 +38,13 @@
</div>
</div>
@if(! $unsecureUsers->isEmpty())
@if(!$unsecure_users->isEmpty())
<hr>
<div class="panel panel-danger">
<div class="panel-heading">{{ trans('dashboard.settings.security.two-factor') }}</div>
<div class="list-group">
@foreach($unsecureUsers as $user)
@foreach($unsecure_users as $user)
<div class="list-group-item">
<strong>{{ $user->username }}</strong>
<span class="label label-danger pull-right"><i class="ion-ios-unlocked"></i></span>

View File

@@ -8,7 +8,7 @@
<span class="uppercase">
<i class="icon icon ion-android-alert"></i> {{ trans('dashboard.subscribers.subscribers') }}
</span>
@if($loggedUser->isAdmin)
@if($current_user->isAdmin)
<a class="btn btn-sm btn-success pull-right" href="{{ route('dashboard.subscribers.add') }}">
{{ trans('dashboard.subscribers.add.title') }}
</a>

View File

@@ -28,7 +28,7 @@
<label>{{ trans('forms.user.password') }}</label>
<input type="password" class="form-control" name="password" value="">
</div>
@if($loggedUser->isAdmin)
@if($current_user->isAdmin)
<div class="form-group">
<label>{{ trans('forms.user.user_level') }}</label>
<select name="level" class="form-control">

View File

@@ -26,13 +26,13 @@
</div>
<div class="form-group">
<label>{{ trans('forms.user.password') }}</label>
<input type="password" class="form-control" name="password" value="" {{ !$loggedUser->isAdmin ? "disabled": "" }}>
<input type="password" class="form-control" name="password" value="" {{ !$current_user->isAdmin ? "disabled": "" }}>
</div>
</fieldset>
<div class="form-group">
<button type="submit" class="btn btn-success">{{ trans('forms.update') }}</button>
@if($loggedUser->isAdmin)
@if($current_user->isAdmin)
<a class="btn btn-danger" href="/dashboard/user/{{ $user->id }}/api/regen">{{ trans('cachet.api.revoke') }}</a>
@endif
</div>

View File

@@ -8,7 +8,7 @@
<span class="uppercase">
<i class="icon icon ion-android-alert"></i> {{ trans('dashboard.team.team') }}
</span>
@if($loggedUser->isAdmin)
@if($current_user->isAdmin)
<a class="btn btn-sm btn-success pull-right" href="{{ route('dashboard.team.add') }}">
{{ trans('dashboard.team.add.title') }}
</a>
@@ -21,9 +21,9 @@
<p class="lead">{{ trans('dashboard.team.description') }}</p>
<div class="user-grid">
@foreach($teamMembers as $member)
@foreach($team_members as $member)
<div class="user col-sm-3 col-xs-6">
<a href="@if($loggedUser->id == $member->id) {{ url('dashboard/user') }} @else /dashboard/team/{{ $member->id }} @endif">
<a href="@if($current_user->id == $member->id) {{ url('dashboard/user') }} @else /dashboard/team/{{ $member->id }} @endif">
<img src="{{ $member->gravatar }}">
</a>
<div class="name">{{ $member->username }}</div>

View File

@@ -17,11 +17,11 @@
<fieldset>
<div class="form-group">
<label>{{ trans('forms.user.username') }}</label>
<input type="text" class="form-control" name="username" value="{{ $loggedUser->username }}" required>
<input type="text" class="form-control" name="username" value="{{ $current_user->username }}" required>
</div>
<div class="form-group">
<label>{{ trans('forms.user.email') }}</label>
<input type="email" class="form-control" name="email" value="{{ $loggedUser->email }}" required>
<input type="email" class="form-control" name="email" value="{{ $current_user->email }}" required>
</div>
<div class="form-group">
<label>{{ trans('forms.user.password') }}</label>
@@ -31,8 +31,8 @@
<div class="form-group">
<label>{{ trans('forms.user.api-token') }}</label>
<div class="input-group">
<input type="text" class="form-control" name="api_key" disabled value="{{ $loggedUser->api_key }}">
<a href="/dashboard/user/{{ $loggedUser->id }}/api/regen" class="input-group-addon btn btn-danger">{{ trans('cachet.api.regenerate') }}</a>
<input type="text" class="form-control" name="api_key" disabled value="{{ $current_user->api_key }}">
<a href="/dashboard/user/{{ $current_user->id }}/api/regen" class="input-group-addon btn btn-danger">{{ trans('cachet.api.regenerate') }}</a>
</div>
<span class="help-block">{{ trans('forms.user.api-token-help') }}</span>
</div>
@@ -40,17 +40,17 @@
<div class="form-group">
<label class="checkbox-inline">
<input type="hidden" name="google2fa" value="0">
<input type='checkbox' name="google2fa" value="1" {{ $loggedUser->hasTwoFactor ? "checked" : "" }}>
<input type='checkbox' name="google2fa" value="1" {{ $current_user->hasTwoFactor ? "checked" : "" }}>
{{ trans('forms.setup.enable_google2fa') }}
</label>
</div>
@if($loggedUser->hasTwoFactor)
@if($current_user->hasTwoFactor)
<div class="form-group">
<?php
$google2fa_url = PragmaRX\Google2FA\Vendor\Laravel\Facade::getQRCodeGoogleUrl(
'CachetHQ',
$loggedUser->email,
$loggedUser->google_2fa_secret
$current_user->email,
$current_user->google_2fa_secret
);
?>
<img src="{{ $google2fa_url }}" class="img-responsive">

View File

@@ -17,8 +17,8 @@
<div class="row app-banner">
<div class="col-md-12 text-center">
<?php $bannerType = Setting::get('app_banner_type') ?>
@if($appUrl = Setting::get('app_domain'))
<a href="{{ $appUrl }}"><img src="data:{{ $bannerType }};base64, {{ $bannerImage}}" class="banner-image img-responsive"></a>
@if($app_url = Setting::get('app_domain'))
<a href="{{ $app_url }}"><img src="data:{{ $bannerType }};base64, {{ $bannerImage}}" class="banner-image img-responsive"></a>
@else
<img src="data:{{ $bannerType }};base64, {{ $bannerImage}}" class="banner-image img-responsive">
@endif
@@ -30,26 +30,26 @@
<div class="alert alert-{{ $systemStatus }}">{{ $systemMessage }}</div>
</div>
@if($aboutApp)
@if($about_app)
<div class="about-app">
<h1>{{ trans('cachet.about_this_site') }}</h1>
<p>{!! $aboutApp !!}</p>
<p>{!! $about_app !!}</p>
</div>
@endif
@if(!$componentGroups->isEmpty() || !$ungroupedComponents->isEmpty())
@if(!$component_groups->isEmpty() || !$ungrouped_components->isEmpty())
<div class="section-components">
@include('partials.components')
</div>
@endif
@if($displayMetrics && Setting::get('display_graphs'))
@if($display_metrics && Setting::get('display_graphs'))
<div class="section-metrics">
@include('partials.metrics')
</div>
@endif
@if(!$scheduledMaintenance->isEmpty())
@if(!$scheduled_maintenance->isEmpty())
<div class="section-scheduled">
@include('partials.schedule')
</div>
@@ -57,23 +57,23 @@
<div class="section-timeline">
<h1>{{ trans('cachet.incidents.past') }}</h1>
@foreach($allIncidents as $date => $incidents)
@foreach($all_incidents as $date => $incidents)
@include('partials.incidents', [compact($date), compact($incidents)])
@endforeach
</div>
<nav>
<ul class="pager">
@if($canPageBackward)
@if($can_page_backward)
<li class="previous">
<a href="{{ route('status-page') }}?start_date={{ $previousDate }}">
<a href="{{ route('status-page') }}?start_date={{ $previous_date }}">
<span aria-hidden="true">&larr;</span> {{ trans('cachet.incidents.previous_week') }}
</a>
</li>
@endif
@if($canPageForward)
@if($can_page_forward)
<li class="next">
<a href="{{ route('status-page') }}?start_date={{ $nextDate }}">
<a href="{{ route('status-page') }}?start_date={{ $next_date }}">
{{ trans('cachet.incidents.next_week') }} <span aria-hidden="true">&rarr;</span>
</a>
</li>

View File

@@ -19,7 +19,7 @@
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="header-logo">
<a href="{{ $appUrl }}"><img src="data:{{ Setting::get('app_banner_type') }};base64, {{ $bannerImage}}"></a>
<a href="{{ $app_url }}"><img src="data:{{ Setting::get('app_banner_type') }};base64, {{ $bannerImage}}"></a>
</td>
</tr>
</table>

View File

@@ -1,6 +1,6 @@
<ul class="list-group components">
@if($componentGroups->count() > 0)
@foreach($componentGroups as $componentGroup)
@if($component_groups->count() > 0)
@foreach($component_groups as $componentGroup)
@if($componentGroup->components->count() > 0)
<li class="list-group-item group-name">
<i class="ion-ios-minus-outline group-toggle"></i>
@@ -14,13 +14,13 @@
</div>
@endif
@endforeach
@if($ungroupedComponents->count() > 0)
@if($ungrouped_components->count() > 0)
<li class="list-group-item break"></li>
@endif
@endif
@if($ungroupedComponents->count() > 0)
@foreach($ungroupedComponents as $component)
@if($ungrouped_components->count() > 0)
@foreach($ungrouped_components as $component)
@include('partials.component', compact($component))
@endforeach
@endif

View File

@@ -1,10 +1,10 @@
@if($loggedUser)
@if($current_user)
<div class="sidebar">
<div class="sidebar-inner">
<div class="profile">
<div class="dropdown">
<a class="dropdown-toggle" href="#" id="profile-dropdown" data-toggle="dropdown" aria-expanded="true">
<span class="avatar"><img src="{{ $loggedUser->gravatar }}"></span> <span class="username">{{ $loggedUser->username }}</span>
<span class="avatar"><img src="{{ $current_user->gravatar }}"></span> <span class="username">{{ $current_user->username }}</span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="profile-dropdown">
@@ -35,7 +35,7 @@
<a href="{{ route('dashboard.incidents') }}">
<i class="icon ion-android-alert"></i>
<span>{{ trans('dashboard.incidents.incidents') }}</span>
<span class="label label-info">{{ $incidentCount }}</span>
<span class="label label-info">{{ $incident_count }}</span>
</a>
</li>
<li {!! set_active('dashboard/templates*') !!}>
@@ -48,7 +48,7 @@
<a href="{{ route('dashboard.components') }}">
<i class="icons ion-outlet"></i>
<span>{{ trans('dashboard.components.components') }}</span>
<span class="label label-info">{{ $componentCount }}</span>
<span class="label label-info">{{ $component_count }}</span>
</a>
</li>
<li {!! set_active('dashboard/team*') !!}>

View File

@@ -8,10 +8,10 @@
</div>
<div class="col-sm-6">
<div class="icons">
@if($loggedUser || Setting::get('dashboard_login_link'))
@if($current_user || Setting::get('dashboard_login_link'))
<a href="/dashboard" class="icon-link"><i class="ion-levels"></i> {{ trans('dashboard.dashboard') }}</a>
@endif
@if($loggedUser)
@if($current_user)
<a href="/auth/logout" class="icon-link"><i class="ion-android-exit"></i> {{ trans('dashboard.logout') }}</a>
@endif
<a href="/rss" class="icon-link rss"><i class="ion-social-rss"></i> {{ trans('cachet.rss-feed') }}</a>

View File

@@ -12,7 +12,7 @@
<div class="col-xs-10 col-xs-offset-2 col-sm-11 col-sm-offset-0">
<div class="panel panel-message">
<div class="panel-heading">
@if($loggedUser)
@if($current_user)
<div class="pull-right btn-group">
<a href="/dashboard/incidents/{{ $incident->id }}/edit" class="btn btn-default">{{ trans('forms.edit') }}</a>
<a href="/dashboard/incidents/{{ $incident->id }}/delete" class="btn btn-danger confirm-action" data-method='DELETE'>{{ trans('forms.delete') }}</a>

View File

@@ -5,7 +5,7 @@
<strong>{{ trans('cachet.incidents.scheduled') }}</strong>
</div>
<div class="list-group">
@foreach($scheduledMaintenance as $schedule)
@foreach($scheduled_maintenance as $schedule)
<div class="list-group-item">
<strong>{{ $schedule->name }}</strong> <small class="date"><abbr class="timeago" data-toggle="tooltip" data-placement="right" title="{{ $schedule->scheduled_at_formatted }}" data-timeago="{{ $schedule->scheduled_at_iso }}"></abbr></small>
{!! $schedule->formattedMessage !!}

View File

@@ -1,11 +1,11 @@
@if($themeSetup)
@if($theme_setup)
<style type="text/css">
body.status-page {
@if($themeBackgroundColor)
background-color: {{ $themeBackgroundColor }};
@if($theme_background_color)
background-color: {{ $theme_background_color }};
@endif
@if($themeTextColor)
color: {{ $themeTextColor }};
@if($theme_text_color)
color: {{ $theme_text_color }};
@endif
}
</style>

View File

@@ -34,7 +34,7 @@
<label>{{ trans('forms.setup.cache_driver') }}</label>
<select name="env[cache_driver]" class="form-control" required>
<option disabled>{{ trans('forms.setup.cache_driver') }}</option>
@foreach($cacheDrivers as $driver => $driverName)
@foreach($cache_drivers as $driver => $driverName)
<option value="{{ $driver }}" {{ Input::old('env.cache_driver') == $driver ? "selected" : null }}>{{ $driverName }}</option>
@endforeach
</select>
@@ -46,7 +46,7 @@
<label>{{ trans('forms.setup.session_driver') }}</label>
<select name="env[session_driver]" class="form-control" required>
<option disabled>{{ trans('forms.setup.session_driver') }}</option>
@foreach($cacheDrivers as $driver => $driverName)
@foreach($cache_drivers as $driver => $driverName)
<option value="{{ $driver }}" {{ Input::old('env.session_driver') == $driver ? "selected" : null }}>{{ $driverName }}</option>
@endforeach
</select>

View File

@@ -11,8 +11,8 @@
<div class="row app-banner">
<div class="col-md-12 text-center">
<?php $bannerType = Setting::get('app_banner_type') ?>
@if($appUrl = Setting::get('app_domain'))
<a href="{{ $appUrl }}"><img src="data:{{ $bannerType }};base64, {{ $bannerImage}}" class="banner-image img-responsive"></a>
@if($app_url = Setting::get('app_domain'))
<a href="{{ $app_url }}"><img src="data:{{ $bannerType }};base64, {{ $bannerImage}}" class="banner-image img-responsive"></a>
@else
<img src="data:{{ $bannerType }};base64, {{ $bannerImage}}" class="banner-image img-responsive">
@endif
@@ -20,10 +20,10 @@
</div>
@endif
@if($aboutApp)
@if($about_app)
<div class="about-app">
<h1>{{ trans('cachet.about_this_site') }}</h1>
<p>{!! $aboutApp !!}</p>
<p>{!! $about_app !!}</p>
</div>
@endif