當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Stats::where方法代碼示例

本文整理匯總了PHP中Stats::where方法的典型用法代碼示例。如果您正苦於以下問題:PHP Stats::where方法的具體用法?PHP Stats::where怎麽用?PHP Stats::where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Stats的用法示例。


在下文中一共展示了Stats::where方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getSparklinesData

 public function getSparklinesData($ids)
 {
     $ids = explode(',', $ids);
     if (count($ids) > 10) {
         $ids = array_slice($ids, 0, 10);
     }
     $response = array();
     foreach ($ids as $key => $id) {
         $response[$id]['total'] = Stats::where('id_link', $id)->lists('total');
         $response[$id]['dif_total'] = Stats::where('id_link', $id)->lists('dif_total');
     }
     return Response::json(array('data' => $response));
 }
開發者ID:vmariano,項目名稱:shared-links-ranking,代碼行數:13,代碼來源:ApiController.php

示例2: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     try {
         $log = new Process();
         $log->name = "get-shares";
         $log->status = "running";
         $log->save();
         $filterDate = new DateTime('now');
         $filterDate->sub(new DateInterval('P1D'));
         //Load shares
         Link::where('date', '>', $filterDate)->chunk(100, function ($links) {
             foreach ($links as $value) {
                 $shares = $this->getSharesCount($value->final_url);
                 $ref = Stats::where('id_link', $value->id)->orderBy('created_at', 'DESC')->first();
                 if (!$ref) {
                     $ref = new stdClass();
                     $ref->total = 0;
                 }
                 $stat = new Stats();
                 $stat->id_link = $value->id;
                 $stat->facebook = $shares['facebook'] != null ? $shares['facebook'] : $value->facebook;
                 $stat->twitter = $shares['twitter'] != null ? $shares['twitter'] : $value->twitter;
                 $stat->linkedin = $shares['linkedin'] != null ? $shares['linkedin'] : $value->linkedin;
                 $stat->googleplus = $shares['googleplus'] != null ? $shares['googleplus'] : $value->googleplus;
                 $stat->total = $stat->facebook + $stat->twitter + $stat->linkedin + $stat->googleplus;
                 $stat->dif_total = $stat->total - $ref->total;
                 $stat->save();
                 $value->facebook = $stat->facebook;
                 $value->twitter = $stat->twitter;
                 $value->linkedin = $stat->linkedin;
                 $value->googleplus = $stat->googleplus;
                 $value->total = $stat->total;
                 $value->save();
             }
         });
         $log->status = "finished";
         $log->save();
     } catch (Exception $e) {
         $this->info($url);
         $this->info($e->getMessage());
     }
 }
開發者ID:vmariano,項目名稱:shared-links-ranking,代碼行數:47,代碼來源:SharesCommand.php


注:本文中的Stats::where方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。