本文整理汇总了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'));
}
示例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;
}
示例3: scopeNotYetPublished
public function scopeNotYetPublished(Builder $query)
{
$now = Carbon::now();
return $query->whereDate('books.published_date', '>', $now);
}
示例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;
}
示例5: scopeThisWeek
public function scopeThisWeek(Builder $q)
{
$q->whereDate($this->startFieldName(), '>=', Carbon::today()->startOfWeek())->whereDate($this->endFieldName(), '<=', Carbon::today()->endOfWeek());
}