/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle(Request $request, Closure $next) { if (!subscribers_enabled()) { return Redirect::route('status-page'); } return $next($request); }
/** * We're verifying that subscribers is both enabled and configured. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { if (!subscribers_enabled()) { return Redirect::route('explore'); } return $next($request); }
/** * Create a new incident. * * @param \Illuminate\Contracts\Auth\Guard $auth * * @return \Illuminate\Http\JsonResponse */ public function postIncidents(Guard $auth) { $incidentData = Binput::all(); if (!array_has($incidentData, 'visible')) { $incidentData['visible'] = 1; } try { $incident = Incident::create($incidentData); } catch (Exception $e) { throw new BadRequestHttpException(); } if (array_get($incidentData, 'notify') && subscribers_enabled()) { event(new IncidentHasReportedEvent($incident)); } return $this->item($incident); }
/** * Create a new incident. * * @param \Illuminate\Contracts\Auth\Guard $auth * * @return \Illuminate\Http\JsonResponse */ public function postIncidents(Guard $auth) { $incidentData = array_filter(Binput::only(['name', 'message', 'status', 'component_id', 'notify', 'visible'])); // Default visibility is 1. if (!array_has($incidentData, 'visible')) { $incidentData['visible'] = 1; } try { $incident = Incident::create($incidentData); } catch (Exception $e) { throw new BadRequestHttpException(); } if (array_get($incidentData, 'notify') && subscribers_enabled()) { event(new IncidentHasReportedEvent($incident)); } return $this->item($incident); }
/** * Creates a new incident. * * @return \Illuminate\Http\RedirectResponse */ public function createIncidentAction() { $incidentData = Binput::get('incident'); $componentStatus = array_pull($incidentData, 'component_status'); if (array_has($incidentData, 'created_at') && $incidentData['created_at']) { $incidentDate = Date::createFromFormat('d/m/Y H:i', $incidentData['created_at'], Setting::get('app_timezone'))->setTimezone(Config::get('app.timezone')); $incidentData['created_at'] = $incidentDate; $incidentData['updated_at'] = $incidentDate; } else { unset($incidentData['created_at']); } try { $incident = Incident::create($incidentData); } catch (ValidationException $e) { return Redirect::route('dashboard.incidents.add')->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]); } if (array_get($incidentData, 'notify') && subscribers_enabled()) { event(new IncidentHasReportedEvent($incident)); } return Redirect::route('dashboard.incidents.add')->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.add.success'))); }
/** * Creates a new scheduled maintenance "incident". * * @return \Illuminate\Http\RedirectResponse */ public function addScheduleAction() { $scheduleData = Binput::get('incident'); // Parse the schedule date. $scheduledAt = Date::createFromFormat('d/m/Y H:i', $scheduleData['scheduled_at'], Setting::get('app_timezone'))->setTimezone(Config::get('app.timezone')); if ($scheduledAt->isPast()) { $messageBag = new MessageBag(); $messageBag->add('scheduled_at', trans('validation.date', ['attribute' => 'scheduled time you supplied'])); return Redirect::back()->withErrors($messageBag); } $scheduleData['scheduled_at'] = $scheduledAt; // Bypass the incident.status field. $scheduleData['status'] = 0; 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()); } if (array_get($scheduleData, 'notify') && subscribers_enabled()) { event(new MaintenanceHasScheduledEvent($incident)); } return Redirect::back()->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.add.success'))); }