class Carbon\Carbon 的对象无法转换为 int LARAVEL

Object of class Carbon\Carbon could not be converted to int LARAVEL

如果我想 return 状态 "Match will start soon".

的时间表已过期,我该如何实施

代码如下:

 @if($match->schedule > 0)
      &nbsp;<strong id="match_schedule">Match will start soon</strong>
 @endif

我试过了:

@if($match->schedule > $match->schedule)
      &nbsp;<strong id="match_schedule">Match will start soon</strong>
@endif

但它不起作用。有什么想法吗?

您似乎在尝试将 Carbon 实例与 int 0 进行比较。这会导致异常:

Object of class Carbon\Carbon could not be converted to int.

您可以通过这样比较来检查时间表是否在过去:

@if($match->schedule < Carbon\Carbon::now())
    &nbsp;<strong id="match_schedule">Match will start soon</strong>
@endif