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


PHP Check::findOrFail方法代码示例

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


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

示例1: checkLatency

 public function checkLatency($id)
 {
     $check = Check::findOrFail($id);
     $data = DB::table('checks_results')->select(array(DB::raw('UNIX_TIMESTAMP(`created_at`) * 1000 AS `x`'), DB::raw('`latency` AS `y`')))->where('check_id', '=', $check->id)->where('created_at', '>', DB::raw('NOW() - INTERVAL 1 WEEK'))->orderBy('created_at', 'asc')->get();
     $data = array_map(function ($result) use($check) {
         return array('x' => (int) $result->x, 'y' => (int) $result->y, 'color' => $result->y / 1000 < $check->latency_tolerating ? $result->y / 1000 < $check->latency_satisfied ? '#A1CF64' : '#F05940' : '#D95C5C');
     }, $data);
     return array(array('name' => trans('check.latency'), 'data' => $data));
 }
开发者ID:dbirchak,项目名称:ping,代码行数:9,代码来源:ApiController.php

示例2: fire

 public function fire(Illuminate\Queue\Jobs\Job $job, $data)
 {
     $check = Check::findOrFail($data);
     $headers = array();
     $options = array();
     if (!empty($check->username)) {
         $options['auth'] = array($check->username, $check->password);
     }
     try {
         $latencyStart = microtime(true);
         $response = Requests::get($check->url, $headers, $options);
         $latency = round((microtime(true) - $latencyStart) * 1000);
     } catch (Requests_Exception $e) {
         $latency = round((microtime(true) - $latencyStart) * 1000);
         if (CheckResult::create(array('check_id' => $check->id, 'status_code' => 0, 'success' => false, 'latency' => $latency, 'content' => trans('check.errors.resolve-host', array('host' => $check->url))))) {
             $job->delete();
         } else {
             $job->release();
         }
         return true;
     }
     $lastCheck = CheckResult::where('check_id', '=', $check->id)->orderBy('created_at', 'desc')->first();
     if ($response->success) {
         if (isset($lastCheck) && !$lastCheck->success) {
             Mail::queue('email.check.online', array('id' => $check->id, 'title' => $check->title), function ($message) use($check) {
                 $message->to($check->theUser->email)->subject(trans('check.job.email.online.subject', array('title' => $check->title)));
             });
         }
         if (CheckResult::create(array('check_id' => $check->id, 'status_code' => $response->status_code, 'success' => true, 'latency' => $latency))) {
             $job->delete();
         } else {
             $job->release();
         }
     } else {
         if (isset($lastCheck) && $lastCheck->success) {
             Mail::queue('email.check.offline', array('id' => $check->id, 'title' => $check->title, 'statusCode' => $response->status_code), function ($message) use($check) {
                 $message->to($check->theUser->email)->subject(trans('check.job.email.offline.subject', array('title' => $check->title)));
             });
         }
         if (CheckResult::create(array('check_id' => $check->id, 'status_code' => $response->status_code, 'success' => false, 'content' => $response->body, 'headers' => json_encode($response->headers), 'latency' => $latency))) {
             $job->delete();
         } else {
             $job->release();
         }
     }
 }
开发者ID:dbirchak,项目名称:ping,代码行数:46,代码来源:CheckWebsite.php

示例3: unpause

 public function unpause($id)
 {
     $check = Check::findOrFail($id);
     $check->paused = false;
     $check->save();
     Session::flash('success', trans('check.unpause.success'));
     return Redirect::route('check.index');
 }
开发者ID:dbirchak,项目名称:ping,代码行数:8,代码来源:CheckController.php


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