当前位置: 首页>>代码示例>>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;未经允许,请勿转载。