Exemplo n.º 1
0
 /**
  * Update an existing incident.
  *
  * @param \CachetHQ\Cachet\Models\Inicdent $incident
  *
  * @return \CachetHQ\Cachet\Models\Incident
  */
 public function putIncident(Incident $incident)
 {
     $incident->update(Binput::all());
     if ($incident->isValid('updating')) {
         return $this->item($incident);
     }
     throw new BadRequestHttpException();
 }
Exemplo n.º 2
0
 /**
  * Updates the given incident.
  *
  * @param \CachetHQ\Cachet\Models\Incident $schedule
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function editScheduleAction(Incident $schedule)
 {
     $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;
     $schedule->update($scheduleData);
     if (!$schedule->isValid()) {
         segment_track('Dashboard', ['event' => 'Edited Schedule', 'success' => false]);
         return Redirect::back()->withInput(Binput::all())->with('title', sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.edit.failure')))->with('errors', $schedule->getErrors());
     }
     segment_track('Dashboard', ['event' => 'Edited Schedule', 'success' => true]);
     $successMsg = sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.edit.success'));
     return Redirect::to('dashboard/schedule')->with('success', $successMsg);
 }
 /**
  * Edit an incident.
  *
  * @param \CachetHQ\Cachet\Models\Incident $incident
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function editIncidentAction(Incident $incident)
 {
     $incidentData = Binput::get('incident');
     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']);
     }
     $incident->update($incidentData);
     if (!$incident->isValid()) {
         segment_track('Dashboard', ['event' => 'Edited Incident', 'success' => false]);
         return Redirect::back()->withInput(Binput::all())->with('title', sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.templates.edit.failure')))->with('errors', $incident->getErrors());
     }
     $componentStatus = array_pull($incidentData, 'component_status');
     if ($incident->component) {
         $incident->component->update(['status' => $componentStatus]);
     }
     segment_track('Dashboard', ['event' => 'Edited Incident', 'success' => true]);
     $successMsg = sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.edit.success'));
     return Redirect::to('dashboard/incidents')->with('success', $successMsg);
 }