laravel-5 - Carbon\Carbon 类的对象无法转换为 int LARAVEL
问题描述
如果时间表已过期,我该如何实施,我想在哪里返回“比赛将很快开始”的状态。
这是代码:
@if($match->schedule > 0)
<strong id="match_schedule">Match will start soon</strong>
@endif
我试过了 :
@if($match->schedule > $match->schedule)
<strong id="match_schedule">Match will start soon</strong>
@endif
但它不起作用。有任何想法吗?
解决方案
您似乎正在尝试将 Carbon 实例与 int 进行比较0
。这会导致异常:
Carbon\Carbon 类的对象无法转换为 int。
您可以通过这样的比较来检查时间表是否在过去:
@if($match->schedule < Carbon\Carbon::now())
<strong id="match_schedule">Match will start soon</strong>
@endif
推荐阅读
- eclipse - 运行并关闭后,我无法再调整我的 gui 大小
- powershell - CutePDF Writer 通过 Powershell
- python - 合并列表是将 pandas 数据框的多列转换为一列中的单个列表
- web - 如何确定 Web 连接器中的哪个应用程序正在调用 Web 服务?
- javascript - TypeError:在数组上映射时,null 不是对象
- sql-server - SQL:如何对数据范围参数进行 IF 检查
- sql - T-SQL 联合(不同,不是全部)和按优先级排序
- javascript - 将 mysql 表下载到 csv 按钮的 Javascript
- symfony - 未检测到 Symfony4 学说 utf8mb4
- c++ - 在 C++ 中使用两级模板的问题