In my laravel model i am using
getTimeagoAttribute()
in this function i am try to get that timeago value for example when i post one review at 11.30 and now the time is 12:30 means i want to display 1 hour ago near the review and code inside my function is
public function getTimeagoAttribute()
{
$mytime = \Carbon\Carbon::now();
$date = $mytime->toDateTimeString()->diffForHumans();
return $date;
}
When i try to run the code its show me an error Call to a member function diffForHumans() on string
is this correct way to achieve what i want or is there any other method to acheive this..
This is how i achieve in my blade view
<span class="pull-right"></span>
please help me out to achieve this ..
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2qyrHBm
via IFTTT
Aucun commentaire:
Enregistrer un commentaire