I want to define an accessor for the created_at field. My code is:
public function getCreatedAtAttribute($value) {
return $value->diffForHumans();
}
It throws an Call to a member function diffForHumans() on null error.
But $task->created_at->diffForHumans(); works fine in the view.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire