/** * 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); }
/** * @dataProvider textFormattingData */ public function testTextFormatting($format, $expected) { $ago = new DateTimeAgo(new PolishTextTranslator()); $formattedText = $ago->getText(new \DateInterval($format), new \DateTime()); $this->assertEquals($expected, $formattedText); }