本文整理汇总了PHP中CachetHQ\Cachet\Models\Incident::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Incident::update方法的具体用法?PHP Incident::update怎么用?PHP Incident::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CachetHQ\Cachet\Models\Incident
的用法示例。
在下文中一共展示了Incident::update方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: putIncident
/**
* 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();
}
示例2: putIncident
/**
* 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);
}
示例3: putIncident
/**
* 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);
}
示例4: editIncidentAction
/**
* 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')));
}
示例5: editScheduleAction
/**
* 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')));
}
示例6: editScheduleAction
/**
* 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);
}
示例7: editIncidentAction
/**
* 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);
}
示例8: editScheduleAction
/**
* 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')));
}