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
 /**
  * Update an existing incident.
  *
  * @param \CachetHQ\Cachet\Models\Inicdent $incident
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function putIncident(Incident $incident)
 {
     try {
         $incident->update(Binput::all());
     } catch (Exception $e) {
         throw new BadRequestHttpException();
     }
     return $this->item($incident);
 }
Exemplo n.º 3
0
 /**
  * Update an existing incident.
  *
  * @param \CachetHQ\Cachet\Models\Inicdent $incident
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function putIncident(Incident $incident)
 {
     $incidentData = array_filter(Binput::only(['name', 'message', 'status', 'component_id', 'notify', 'visible']));
     try {
         $incident->update($incidentData);
     } catch (Exception $e) {
         throw new BadRequestHttpException();
     }
     return $this->item($incident);
 }
Exemplo n.º 4
0
 /**
  * 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']);
     }
     try {
         $incident->update($incidentData);
     } catch (ValidationException $e) {
         return Redirect::route('dashboard.incidents.edit', ['id' => $incident->id])->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]);
     }
     return Redirect::route('dashboard.incidents.edit', ['id' => $incident->id])->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.edit.success')));
 }
Exemplo n.º 5
0
 /**
  * Updates the given incident.
  *
  * @param \CachetHQ\Cachet\Models\Incident   $schedule
  * @param \CachetHQ\Cachet\Dates\DateFactory $dates
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function editScheduleAction(Incident $schedule, DateFactory $dates)
 {
     $scheduleData = Binput::get('incident');
     // Parse the schedule date.
     $scheduledAt = $dates->createNormalized('d/m/Y H:i', $scheduleData['scheduled_at']);
     if ($scheduledAt->isPast()) {
         $messageBag = new MessageBag();
         $messageBag->add('scheduled_at', trans('validation.date', ['attribute' => 'scheduled time you supplied']));
         return Redirect::route('dashboard.schedule.edit', ['id' => $schedule->id])->withErrors($messageBag);
     }
     $scheduleData['scheduled_at'] = $scheduledAt;
     // Bypass the incident.status field.
     $scheduleData['status'] = 0;
     try {
         $schedule->update($scheduleData);
     } catch (ValidationException $e) {
         return Redirect::route('dashboard.schedule.edit', ['id' => $schedule->id])->withInput(Binput::all())->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.edit.failure')))->withErrors($e->getMessageBag());
     }
     return Redirect::route('dashboard.schedule.edit', ['id' => $schedule->id])->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.edit.success')));
 }
Exemplo n.º 6
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);
 }
Exemplo n.º 8
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;
     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());
     }
     return Redirect::to('dashboard/schedule')->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.edit.success')));
 }