php – Laravel雄辩的日期范围

php – Laravel雄辩的日期范围,第1张

概述我正在创建报告页面,我想做的是从特定日期到具体日期显示报告.我当前的代码是: $now = date('Y-m-d');$reservations = Reservation::where('reservation_from', $now)->get(); 这样做是从表中选择*,其中reservation_from = $现在.我在这里有一个查询,但我不知道如何将它转换成雄辩的查询.这是我的代码 我正在创建报告页面,我想做的是从特定日期到具体日期显示报告.我当前的代码是:
$Now = date('Y-m-d');$reservations = Reservation::where('reservation_from',$Now)->get();

这样做是从表中选择*,其中reservation_from = $现在.我在这里有一个查询,但我不知道如何将它转换成雄辩的查询.这是我的代码:

SELECT * FROM table WHERE reservation_from BETWEEN '$from' AND '$to

如何将代码转换为雄辩的查询?先谢谢你.

The whereBetween method verifIEs that a column’s value is between
two values.

尝试:

$reservations = Reservation::whereBetween('reservation_from',[$from,$to])->get();

如果你想添加更多的条件,你可以使用或WhereBetween.

$reservations = Reservation::whereBetween('reservation_from',[$from_from,$to_from])                ->orWhereBetween('reservation_to',[$from_to,$to_to])                ->get();

你应该知道:whereNotBetween,whereIn,wherenotin,whereNull,whereNotNull

Laravel docs about where.

总结

以上是内存溢出为你收集整理的php – Laravel雄辩的日期范围全部内容,希望文章能够帮你解决php – Laravel雄辩的日期范围所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1258435.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)

保存