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


PHP Incident::create方法代码示例

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


在下文中一共展示了Incident::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle

 /**
  * Handle the report incident command.
  *
  * @param \CachetHQ\Cachet\Commands\Incident\ReportIncidentCommand $command
  *
  * @return \CachetHQ\Cachet\Models\Incident
  */
 public function handle(ReportIncidentCommand $command)
 {
     if ($command->template) {
         $command->message = $this->parseIncidentTemplate($command->template, $command->template_vars);
     }
     $data = ['name' => $command->name, 'status' => $command->status, 'message' => $command->message, 'visible' => $command->visible];
     // Link with the component.
     if ($command->component_id) {
         $data['component_id'] = $command->component_id;
     }
     // The incident occurred at a different time.
     if ($command->incident_date) {
         $incidentDate = $this->dates->createNormalized('d/m/Y H:i', $command->incident_date);
         $data['created_at'] = $incidentDate;
         $data['updated_at'] = $incidentDate;
     }
     // Create the incident
     $incident = Incident::create($data);
     // Update the component.
     if ($command->component_id) {
         Component::find($command->component_id)->update(['status' => $command->component_status]);
     }
     $incident->notify = (bool) $command->notify;
     event(new IncidentWasReportedEvent($incident));
     return $incident;
 }
开发者ID:minhkiller,项目名称:Cachet,代码行数:33,代码来源:ReportIncidentCommandHandler.php

示例2: handle

 /**
  * Handle the report maintenance command.
  *
  * @param \CachetHQ\Cachet\Commands\Incident\ReportMaintenanceCommand $command
  *
  * @return \CachetHQ\Cachet\Models\Incident
  */
 public function handle(ReportMaintenanceCommand $command)
 {
     $scheduledAt = $this->dates->createNormalized('d/m/Y H:i', $command->timestamp);
     $maintenanceEvent = Incident::create(['name' => $command->name, 'message' => $command->message, 'scheduled_at' => $scheduledAt, 'status' => 0, 'visible' => 1]);
     event(new MaintenanceWasScheduledEvent($maintenanceEvent));
     return $maintenanceEvent;
 }
开发者ID:rafix82,项目名称:Cachet,代码行数:14,代码来源:ReportMaintenanceCommandHandler.php

示例3: addScheduleAction

 /**
  * 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;
     $incident = Incident::create($scheduleData);
     if (!$incident->isValid()) {
         segment_track('Dashboard', ['event' => 'Created Scheduled Maintenance', 'success' => false]);
         return Redirect::back()->withInput(Binput::all())->with('success', sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.add.failure')))->with('errors', $incident->getErrors());
     }
     segment_track('Dashboard', ['event' => 'Created Scheduled Maintenance', 'success' => true]);
     $successMsg = sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.schedule.add.success'));
     $isEnabled = (bool) Setting::get('enable_subscribers', false);
     $mailAddress = env('MAIL_ADDRESS', false);
     $mailFrom = env('MAIL_NAME', false);
     $subscribersEnabled = $isEnabled && $mailAddress && $mailFrom;
     if (array_get($scheduleData, 'notify') && $subscribersEnabled) {
         event(new MaintenanceHasScheduledEvent($incident));
     }
     return Redirect::back()->with('success', $successMsg);
 }
开发者ID:hd-deman,项目名称:Cachet,代码行数:34,代码来源:ScheduleController.php

示例4: handle

 /**
  * Handle the report incident command.
  *
  * @param \CachetHQ\Cachet\Commands\Incident\ReportIncidentCommand $command
  *
  * @return \CachetHQ\Cachet\Models\Incident
  */
 public function handle(ReportIncidentCommand $command)
 {
     $data = ['name' => $command->name, 'status' => $command->status, 'message' => $command->message, 'visible' => $command->visible];
     // Link with the component.
     if ($command->component_id) {
         $data['component_id'] = $command->component_id;
     }
     // The incident occurred at a different time.
     if ($command->incident_date) {
         $incidentDate = Date::createFromFormat('d/m/Y H:i', $command->incident_date, config('cachet.timezone'))->setTimezone(Config::get('app.timezone'));
         $data['created_at'] = $incidentDate;
         $data['updated_at'] = $incidentDate;
     }
     // Create the incident
     $incident = Incident::create($data);
     // Update the component.
     if ($command->component_id) {
         Component::find($command->component_id)->update(['status' => $command->component_status]);
     }
     // Notify subscribers.
     if ($command->notify) {
         event(new IncidentWasReportedEvent($incident));
     }
     return $incident;
 }
开发者ID:ryanwinchester-forks,项目名称:Cachet,代码行数:32,代码来源:ReportIncidentCommandHandler.php

示例5: seedIncidents

 /**
  * Seed the incidents table.
  *
  * @return void
  */
 protected function seedIncidents()
 {
     $defaultIncidents = [['name' => 'Awesome', 'message' => 'We totally nailed the fix :smile:', 'status' => 4, 'component_id' => 0, 'scheduled_at' => null, 'visible' => 1], ['name' => 'Monitoring the fix', 'message' => "We're checking that our fix will first work.", 'status' => 3, 'component_id' => 0, 'scheduled_at' => null, 'visible' => 1], ['name' => 'Update', 'message' => "We've found the problem, so we're looking at it.", 'status' => 2, 'component_id' => 0, 'scheduled_at' => null, 'visible' => 1], ['name' => 'Test Incident', 'message' => 'Something went wrong, oh noes.', 'status' => 1, 'component_id' => 0, 'scheduled_at' => null, 'visible' => 1]];
     Incident::truncate();
     foreach ($defaultIncidents as $incident) {
         Incident::create($incident);
     }
 }
开发者ID:seanherron,项目名称:Cachet,代码行数:13,代码来源:DemoSeederCommand.php

示例6: handle

 /**
  * Handle the report maintenance command.
  *
  * @param \CachetHQ\Cachet\Commands\Incident\ReportMaintenanceCommand $command
  *
  * @return \CachetHQ\Cachet\Models\Incident
  */
 public function handle(ReportMaintenanceCommand $command)
 {
     $scheduledAt = Date::createFromFormat('d/m/Y H:i', $command->timestamp, config('cachet.timezone'))->setTimezone(Config::get('app.timezone'));
     $maintenanceEvent = Incident::create(['name' => $command->name, 'message' => $command->message, 'scheduled_at' => $scheduledAt, 'status' => 0, 'visible' => 1]);
     // Notify subscribers.
     event(new MaintenanceWasScheduledEvent($maintenanceEvent));
     return $maintenanceEvent;
 }
开发者ID:ryanwinchester-forks,项目名称:Cachet,代码行数:15,代码来源:ReportMaintenanceCommandHandler.php

示例7: run

 /**
  * Run the database seeding.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     $defaultIncidents = [["name" => "Awesome", "message" => "We totally nailed the fix.", "status" => 4, "component_id" => 0, "user_id" => 1], ["name" => "Monitoring the fix", "message" => "We're checking that our fix will first work.", "status" => 3, "component_id" => 0, "user_id" => 1], ["name" => "Update", "message" => "We've found the problem, so we're looking at it.", "status" => 2, "component_id" => 0, "user_id" => 1], ["name" => "Test Incident", "message" => "Something went wrong, oh noes.", "component_id" => 0, "user_id" => 1]];
     Incident::truncate();
     foreach ($defaultIncidents as $incident) {
         Incident::create($incident);
     }
 }
开发者ID:baa-archieve,项目名称:Cachet,代码行数:14,代码来源:IncidentTableSeeder.php

示例8: handle

 /**
  * Handle the report maintenance command.
  *
  * @param \CachetHQ\Cachet\Commands\Incident\ReportMaintenanceCommand $command
  *
  * @return \CachetHQ\Cachet\Models\Incident
  */
 public function handle(ReportMaintenanceCommand $command)
 {
     // TODO: Add validation to scheduledAt
     $scheduledAt = Date::createFromFormat('d/m/Y H:i', $command->timestamp, Setting::get('app_timezone'))->setTimezone(Config::get('app.timezone'));
     $maintenanceEvent = Incident::create(['name' => $command->name, 'message' => $command->message, 'scheduled_at' => $scheduledAt, 'status' => 0, 'visible' => 1]);
     // Notify subscribers.
     if ($command->notify) {
         event(new MaintenanceWasScheduledEvent($maintenanceEvent));
     }
     return $maintenanceEvent;
 }
开发者ID:practico,项目名称:Cachet,代码行数:18,代码来源:ReportMaintenanceCommandHandler.php

示例9: handle

 /**
  * Handle the report incident command.
  *
  * @param \CachetHQ\Cachet\Commands\Incident\ReportIncidentCommand $command
  *
  * @return \CachetHQ\Cachet\Models\Incident
  */
 public function handle(ReportIncidentCommand $command)
 {
     $incident = Incident::create(['name' => $command->name, 'status' => $command->status, 'message' => $command->message, 'visible' => $command->visible, 'component' => $command->component_id]);
     // Update the component.
     if ($command->component_id) {
         Component::find($command->component_id)->update(['status' => $command->component_status]);
     }
     // Notify subscribers.
     if ($command->notify) {
         event(new IncidentWasReportedEvent($incident));
     }
     return $incident;
 }
开发者ID:practico,项目名称:Cachet,代码行数:20,代码来源:ReportIncidentCommandHandler.php

示例10: postIncidents

 /**
  * 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);
 }
开发者ID:RetinaInc,项目名称:Cachet,代码行数:23,代码来源:IncidentController.php

示例11: postIncidents

 /**
  * 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);
 }
开发者ID:THoracek,项目名称:Cachet,代码行数:24,代码来源:IncidentController.php

示例12: postIncidents

 /**
  * Create a new incident.
  *
  * @param \Illuminate\Contracts\Auth\Guard $auth
  *
  * @return \CachetHQ\Cachet\Models\Incident
  */
 public function postIncidents(Guard $auth)
 {
     $incidentData = Binput::all();
     try {
         $incident = Incident::create($incidentData);
     } catch (Exception $e) {
         throw new BadRequestHttpException();
     }
     $isEnabled = (bool) Setting::get('enable_subscribers', false);
     $mailAddress = env('MAIL_ADDRESS', false);
     $mailFrom = env('MAIL_NAME', false);
     $subscribersEnabled = $isEnabled && $mailAddress && $mailFrom;
     if (array_get($incidentData, 'notify') && $subscribersEnabled) {
         event(new IncidentHasReportedEvent($incident));
     }
     if ($incident->isValid()) {
         return $this->item($incident);
     }
     throw new BadRequestHttpException();
 }
开发者ID:2bj,项目名称:Cachet,代码行数:27,代码来源:IncidentController.php

示例13: addScheduleAction

 /**
  * 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')));
 }
开发者ID:ephillipe,项目名称:Cachet,代码行数:28,代码来源:ScheduleController.php

示例14: seedIncidents

    /**
     * Seed the incidents table.
     *
     * @return void
     */
    protected function seedIncidents()
    {
        $incidentMessage = <<<'EINCIDENT'
# Of course it does!

What kind of web application doesn't these days?

## Headers are fun aren't they

It's _exactly_ why we need Markdown. For **emphasis** and such.
EINCIDENT;
        $defaultIncidents = [['name' => 'Cachet supports Markdown!', 'message' => $incidentMessage, 'status' => 4, 'component_id' => 0, 'scheduled_at' => null, 'visible' => 1], ['name' => 'Awesome', 'message' => ':+1: We totally nailed the fix.', 'status' => 4, 'component_id' => 0, 'scheduled_at' => null, 'visible' => 1], ['name' => 'Monitoring the fix', 'message' => ":ship: We've deployed a fix.", 'status' => 3, 'component_id' => 0, 'scheduled_at' => null, 'visible' => 1], ['name' => 'Update', 'message' => "We've identified the problem. Our engineers are currently looking at it.", 'status' => 2, 'component_id' => 0, 'scheduled_at' => null, 'visible' => 1], ['name' => 'Test Incident', 'message' => 'Something went wrong, with something or another.', 'status' => 1, 'component_id' => 0, 'scheduled_at' => null, 'visible' => 1], ['name' => 'Investigating the API', 'message' => ':zap: We\'ve seen high response times from our API. It looks to be fixing itself as time goes on.', 'status' => 1, 'component_id' => 1, 'scheduled_at' => null, 'visible' => 1]];
        Incident::truncate();
        foreach ($defaultIncidents as $incident) {
            Incident::create($incident);
        }
    }
开发者ID:R11T,项目名称:Cachet,代码行数:22,代码来源:DemoSeederCommand.php

示例15: createIncidentAction

 /**
  * 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']);
     }
     $incident = Incident::create($incidentData);
     if (!$incident->isValid()) {
         segment_track('Dashboard', ['event' => 'Created Incident', 'success' => false]);
         return Redirect::back()->withInput(Binput::all())->with('title', sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.add.failure')))->with('errors', $incident->getErrors());
     }
     // Update the component.
     if (isset($incidentData['component_id']) && (int) $incidentData['component_id'] > 0) {
         Component::find($incidentData['component_id'])->update(['status' => $componentStatus]);
     }
     segment_track('Dashboard', ['event' => 'Created Incident', 'success' => true]);
     $successMsg = sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.add.success'));
     $isEnabled = (bool) Setting::get('enable_subscribers', false);
     $mailAddress = env('MAIL_ADDRESS', false);
     $mailFrom = env('MAIL_NAME', false);
     $subscribersEnabled = $isEnabled && $mailAddress && $mailFrom;
     if (array_get($incidentData, 'notify') && $subscribersEnabled) {
         event(new IncidentHasReportedEvent($incident));
     }
     return Redirect::back()->with('success', $successMsg);
 }
开发者ID:nguyentamvinhlong,项目名称:Cachet,代码行数:36,代码来源:IncidentController.php


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