John Carlo
John Carlo

Reputation: 54

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

How do I implement if the schedule has been expired where in I want to return a status of "Match will start soon".

here is the code:

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

I tried :

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

but it doesn't work. any ideas?

Upvotes: 0

Views: 181

Answers (1)

piscator
piscator

Reputation: 8739

It seems you are trying to compare a Carbon instance to int 0. This causes the exception:

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

You can check if the schedule lies in the past by comparing it like this:

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

Upvotes: 2

Related Questions