'datetime', ]; public function memes() { return $this->hasMany(Meme::class)->orderByDesc('created_at'); } public function tips() { return $this->hasManyThrough(Tip::class, Meme::class, 'user_id'); } public function getMemesCountAttribute() { return $this->memes->count(); } public function getTipsCountAttribute() { return $this->tips->where('is_deposit', 1)->count(); } public function getTipsTotalAttribute() { if ($this->tips->where('is_deposit', 1)->sum('amount_formatted')) { return rtrim(sprintf('%.8f',floatval( $this->tips->where('is_deposit', 1)->sum('amount_formatted') )),'0'); } else { return 0; } } }