如果计划已经过期,我该如何实施?我希望返回状态“匹配即将开始”。
这是代码:
@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