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


PHP Builder::whereDate方法代碼示例

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


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

示例1: scopeFilterUpcoming

 /**
  * Scope a query to only include upcoming events.
  *
  * @param  \Illuminate\Database\Eloquent\Builder $query
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeFilterUpcoming($query)
 {
     return $query->whereDate('events.start_at', '>=', date('Y-m-d'));
 }
開發者ID:slicvic,項目名稱:wgg,代碼行數:10,代碼來源:Event.php

示例2: filterResultsInTime

 private function filterResultsInTime(Builder &$samplingsQueryBuilder, $request)
 {
     if ($request->date) {
         $samplingsQueryBuilder->whereDate('samplings.created_at', '=', $request->date);
         return true;
     }
     if ($request->exists("today")) {
         $samplingsQueryBuilder->whereDate('samplings.created_at', '=', Carbon::today()->toDateString());
         return true;
     }
     if ($request->exists("yesterday")) {
         $samplingsQueryBuilder->whereDate('samplings.created_at', '=', Carbon::today()->subDay()->toDateString());
         return true;
     }
     if ($request->start) {
         $samplingsQueryBuilder->whereDate('samplings.created_at', '>=', $request->start);
         if ($request->end) {
             $samplingsQueryBuilder->whereDate('samplings.created_at', '<=', $request->end);
         }
         return true;
     }
     return false;
 }
開發者ID:ThomasJust,項目名稱:ISDProject-Online,代碼行數:23,代碼來源:SamplingsController.php

示例3: scopeNotYetPublished

 public function scopeNotYetPublished(Builder $query)
 {
     $now = Carbon::now();
     return $query->whereDate('books.published_date', '>', $now);
 }
開發者ID:ScottBurfieldMills,項目名稱:BookFeed,代碼行數:5,代碼來源:Book.php

示例4: filterResultsInTime

 private function filterResultsInTime(Builder &$samplingsQueryBuilder, $request, Product $product)
 {
     if ($request->date) {
         $samplingsQueryBuilder->whereDate('samplings.created_at', '=', $request->date);
         return true;
     }
     if ($request->exists("today")) {
         $samplingsQueryBuilder->whereDate('samplings.created_at', '=', Carbon::today()->toDateString());
         return true;
     }
     if ($request->exists("yesterday")) {
         $samplingsQueryBuilder->whereDate('samplings.created_at', '=', Carbon::today()->subDay()->toDateString());
         return true;
     }
     if ($request->start) {
         $samplingsQueryBuilder->whereDate('samplings.created_at', '>=', $request->start);
         if ($request->end) {
             $samplingsQueryBuilder->whereDate('samplings.created_at', '<=', $request->end);
         }
         return true;
     }
     if ($request->timeFilter) {
         $secondQueryBuilder = clone $samplingsQueryBuilder;
         $lastSampling = $secondQueryBuilder->take(1)->get(["samplings.created_at"])->first()->created_at->copy();
         switch ($request->timeFilter) {
             case "hour":
                 $lastHour = $lastSampling->subHour()->toDateTimeString();
                 $samplingsQueryBuilder->where("samplings.created_at", ">", $lastHour);
                 break;
             case "today":
                 $today = $lastSampling->toDateString();
                 $samplingsQueryBuilder->whereDate("samplings.created_at", "=", $today);
                 break;
             case "yesterday":
                 $lastDay = $lastSampling->subDay()->toDateString();
                 $samplingsQueryBuilder->whereDate("samplings.created_at", "=", $lastDay);
                 break;
             case "week":
                 $lastWeek = $lastSampling->subWeek()->toDateTimeString();
                 $samplingsQueryBuilder->where("samplings.created_at", ">", $lastWeek);
                 break;
             case "month":
                 $lastMonth = $lastSampling->subMonth()->toDateTimeString();
                 $samplingsQueryBuilder->where("samplings.created_at", ">", $lastMonth);
                 break;
             case "year":
                 $lastYear = $lastSampling->subYear()->toDateTimeString();
                 $samplingsQueryBuilder->where("samplings.created_at", ">", $lastYear);
                 break;
         }
         return true;
     }
     return false;
 }
開發者ID:MetropoliaUAS,項目名稱:ISDProject-Online,代碼行數:54,代碼來源:SamplingsController.php

示例5: scopeThisWeek

 public function scopeThisWeek(Builder $q)
 {
     $q->whereDate($this->startFieldName(), '>=', Carbon::today()->startOfWeek())->whereDate($this->endFieldName(), '<=', Carbon::today()->endOfWeek());
 }
開發者ID:PLANKandre,項目名稱:dashboard,代碼行數:4,代碼來源:TemporalTrait.php


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