That function is part of Carbon, which is what Eloquent uses for datetime fields.
Eloquent timestamps are actually converted into instances of Carbon. diffForHumans() is a method from Carbon.
Just to add to the above: if you want your own model properties (database fields) to be converted into Carbon instances, add them to the Model's dates
property. I detailed this on laravel-tricks.com:
http://www.laravel-tricks.com/tricks/model-date-mutators-an-easier-way
meigwilym said:
Just to add to the above: if you want your own model properties (database fields) to be converted into Carbon instances, add them to the Model's
dates
property. I detailed this on laravel-tricks.com:http://www.laravel-tricks.com/tricks/model-date-mutators-an-easier-way
I didn't know that, thanks.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community