/** * Mutator function to return the pivot timestamp as time ago * @return string * The time since the badge was earned */ public function getTimeAgoAttribute($value) { if (!isset($this->pivot->created_at)) { return null; } $timeAgo = new TimeAgo(); return $timeAgo->get($this->pivot->created_at); }
/** * Mutator function to return the pivot timestamp as time ago * @return string The time since the badge was earned */ public function getTimeAgoAttribute($value) { $timeAgo = new TimeAgo(); return $timeAgo->get($this->timestamp); }