Add tips count to leaderboard

Also rename memes_total to memes_count to make it more consistent
This commit is contained in:
dev 2021-08-10 21:55:34 -07:00
parent bb8ee230a6
commit 4c1b493943
4 changed files with 12 additions and 5 deletions

View file

@ -11,7 +11,7 @@ class User extends Authenticatable
{
use HasFactory, Notifiable;
protected $appends = ['tips_total', 'memes_total'];
protected $appends = ['tips_count', 'tips_total', 'memes_count'];
/**
* The attributes that are mass assignable.
@ -54,11 +54,16 @@ class User extends Authenticatable
return $this->hasManyThrough(Tip::class, Meme::class, 'user_id');
}
public function getMemesTotalAttribute()
public function getMemesCountAttribute()
{
return $this->memes->count();
}
public function getTipsCountAttribute()
{
return $this->tips->where('is_deposit', 1)->count();
}
public function getTipsTotalAttribute()
{
return $this->tips->where('is_deposit', 1)->sum('amount_formatted');