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


PHP Component::find方法代码示例

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


在下文中一共展示了Component::find方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
 {
     $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

示例2: 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

示例3: postUpdateComponentOrder

 /**
  * Updates a components ordering.
  *
  * @return array
  */
 public function postUpdateComponentOrder()
 {
     $componentData = Binput::get('ids');
     foreach ($componentData as $order => $componentId) {
         // Ordering should be 1-based, data comes in 0-based
         Component::find($componentId)->update(['order' => $order + 1]);
     }
     return $componentData;
 }
开发者ID:kulado,项目名称:Cachet,代码行数:14,代码来源:ApiController.php

示例4: postUpdateComponentOrder

 /**
  * Updates a components ordering.
  *
  * @return array
  */
 public function postUpdateComponentOrder()
 {
     $componentData = Binput::all();
     unset($componentData['component'][0]);
     // Remove random 0 index.
     foreach ($componentData['component'] as $componentId => $order) {
         $component = Component::find($componentId);
         $component->update(['order' => $order]);
     }
     return $componentData;
 }
开发者ID:baa-archieve,项目名称:Cachet,代码行数:16,代码来源:DashAPIController.php

示例5: getComponentStatus

 /**
  * Find the status on a component.
  *
  * @param string $componentId
  *
  * @return string
  */
 protected function getComponentStatus($componentId = '')
 {
     if ('' == $componentId) {
         return 'n/a';
     }
     $statuses = trans('cachet.components.status');
     $component = Component::find($componentId);
     if ($component instanceof Component) {
         return $component->name . ': *' . $statuses[$component->status] . '*';
     }
     return 'n/a';
 }
开发者ID:mrbase,项目名称:cachet-slack-integration,代码行数:19,代码来源:BaseHandler.php

示例6: 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

示例7: postUpdateComponentOrder

 /**
  * Updates a components ordering.
  *
  * @return array
  */
 public function postUpdateComponentOrder()
 {
     $componentData = Binput::get('ids');
     foreach ($componentData as $order => $componentId) {
         try {
             $component = Component::find($componentId);
             dispatch(new UpdateComponentCommand($component, $component->name, $component->description, $component->status, $component->link, $order + 1, $component->group_id, $component->enabled));
         } catch (QueryException $e) {
             throw new BadRequestHttpException();
         }
     }
     return $this->collection(Component::query()->orderBy('order')->get());
 }
开发者ID:aksalj,项目名称:Cachet,代码行数:18,代码来源:ApiController.php

示例8: handle

 /**
  * Handle the update incident command.
  *
  * @param \CachetHQ\Cachet\Commands\Incident\UpdateIncidentCommand $command
  *
  * @return \CachetHQ\Cachet\Models\Incident
  */
 public function handle(UpdateIncidentCommand $command)
 {
     $incident = $command->incident;
     $incident->update($this->filterIncidentData($command));
     // The incident occurred at a different time.
     if ($command->incident_date) {
         $incidentDate = $this->dates->createNormalized('d/m/Y H:i', $command->incident_date);
         $incident->update(['created_at' => $incidentDate, 'updated_at' => $incidentDate]);
     }
     // Update the component.
     if ($command->component_id) {
         Component::find($command->component_id)->update(['status' => $command->component_status]);
     }
     event(new IncidentWasUpdatedEvent($incident));
     return $incident;
 }
开发者ID:rafix82,项目名称:Cachet,代码行数:23,代码来源:UpdateIncidentCommandHandler.php

示例9: handle

 /**
  * Handle the update incident command.
  *
  * @param \CachetHQ\Cachet\Commands\Incident\UpdateIncidentCommand $command
  *
  * @return \CachetHQ\Cachet\Models\Incident
  */
 public function handle(UpdateIncidentCommand $command)
 {
     $incident = $command->incident;
     $incident->update($this->filterIncidentData($command));
     // 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'));
         $incident->update(['created_at' => $incidentDate, 'updated_at' => $incidentDate]);
     }
     // Update the component.
     if ($command->component_id) {
         Component::find($command->component_id)->update(['status' => $command->component_status]);
     }
     // Notify subscribers.
     event(new IncidentWasUpdatedEvent($incident));
     return $incident;
 }
开发者ID:ryanwinchester-forks,项目名称:Cachet,代码行数:24,代码来源:UpdateIncidentCommandHandler.php

示例10: 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']);
     }
     try {
         $incident = Incident::create($incidentData);
     } catch (ValidationException $e) {
         return Redirect::route('dashboard.incidents.add')->withInput(Binput::all())->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.add.failure')))->withErrors($e->getMessageBag());
     }
     // Update the component.
     if (isset($incidentData['component_id']) && (int) $incidentData['component_id'] > 0) {
         Component::find($incidentData['component_id'])->update(['status' => $componentStatus]);
     }
     if (array_get($incidentData, 'notify') && subscribers_enabled()) {
         event(new IncidentHasReportedEvent($incident));
     }
     return Redirect::route('dashboard.incidents.add')->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.add.success')));
 }
开发者ID:RetinaInc,项目名称:Cachet,代码行数:30,代码来源:IncidentController.php

示例11: 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\Component::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。