当前位置: 首页>>代码示例>>PHP>>正文


PHP Incident::isValid方法代码示例

本文整理汇总了PHP中CachetHQ\Cachet\Models\Incident::isValid方法的典型用法代码示例。如果您正苦于以下问题:PHP Incident::isValid方法的具体用法?PHP Incident::isValid怎么用?PHP Incident::isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CachetHQ\Cachet\Models\Incident的用法示例。


在下文中一共展示了Incident::isValid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
 }
开发者ID:2bj,项目名称:Cachet,代码行数:15,代码来源:IncidentController.php

示例2: 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);
 }
开发者ID:hd-deman,项目名称:Cachet,代码行数:29,代码来源:ScheduleController.php

示例3: 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);
 }
开发者ID:nguyentamvinhlong,项目名称:Cachet,代码行数:30,代码来源:IncidentController.php


注:本文中的CachetHQ\Cachet\Models\Incident::isValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。