mirror of
https://repo.getmonero.org/AnonDev/xmrmemes.git
synced 2024-12-21 21:55:07 -05:00
Add tips count to leaderboard
Also rename memes_total to memes_count to make it more consistent
This commit is contained in:
parent
bb8ee230a6
commit
4c1b493943
@ -40,7 +40,7 @@ class MemeController extends Controller
|
|||||||
public function leaderboard()
|
public function leaderboard()
|
||||||
{
|
{
|
||||||
SEOTools::setTitle('Leaderboard');
|
SEOTools::setTitle('Leaderboard');
|
||||||
$users = User::with('tips')->has('memes')->get();
|
$users = User::with('tips')->withCount('tips')->has('memes')->get();
|
||||||
$users = $users->sortByDesc(function($user) {
|
$users = $users->sortByDesc(function($user) {
|
||||||
return $user->tips_total;
|
return $user->tips_total;
|
||||||
});
|
});
|
||||||
|
@ -11,7 +11,7 @@ class User extends Authenticatable
|
|||||||
{
|
{
|
||||||
use HasFactory, Notifiable;
|
use HasFactory, Notifiable;
|
||||||
|
|
||||||
protected $appends = ['tips_total', 'memes_total'];
|
protected $appends = ['tips_count', 'tips_total', 'memes_count'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
@ -54,11 +54,16 @@ class User extends Authenticatable
|
|||||||
return $this->hasManyThrough(Tip::class, Meme::class, 'user_id');
|
return $this->hasManyThrough(Tip::class, Meme::class, 'user_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMemesTotalAttribute()
|
public function getMemesCountAttribute()
|
||||||
{
|
{
|
||||||
return $this->memes->count();
|
return $this->memes->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTipsCountAttribute()
|
||||||
|
{
|
||||||
|
return $this->tips->where('is_deposit', 1)->count();
|
||||||
|
}
|
||||||
|
|
||||||
public function getTipsTotalAttribute()
|
public function getTipsTotalAttribute()
|
||||||
{
|
{
|
||||||
return $this->tips->where('is_deposit', 1)->sum('amount_formatted');
|
return $this->tips->where('is_deposit', 1)->sum('amount_formatted');
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th scope="col">User</th>
|
<th scope="col">User</th>
|
||||||
<th scope="col">Meme Count</th>
|
<th scope="col">Meme Count</th>
|
||||||
|
<th scope="col">Tips Count</th>
|
||||||
<th scope="col">Total XMR Tips</th>
|
<th scope="col">Total XMR Tips</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -18,7 +19,8 @@
|
|||||||
@foreach ($data['users'] as $user)
|
@foreach ($data['users'] as $user)
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ url('/user/' . $user->id) }}">{{ $user->name }}</a></td>
|
<td><a href="{{ url('/user/' . $user->id) }}">{{ $user->name }}</a></td>
|
||||||
<td>{{ $user->memes_total }}</td>
|
<td>{{ $user->memes_count }}</td>
|
||||||
|
<td>{{ $user->tips_count }}</td>
|
||||||
<td>{{ $user->tips_total }}</td>
|
<td>{{ $user->tips_total }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<h3 class="text-center mb-3">Memes By {{ $data['user']->name }}</h3>
|
<h3 class="text-center mb-3">Memes By {{ $data['user']->name }}</h3>
|
||||||
<p class="text-center">Total Earnings: {{ $data['user']->tips_total }}</h3>
|
<p class="text-center">Total Earnings: {{ $data['user']->tips_total }}</h3>
|
||||||
<p class="text-center">Total Memes: {{ $data['user']->memes_total }}</h3>
|
<p class="text-center">Total Memes: {{ $data['user']->memes_count }}</h3>
|
||||||
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-4 grid-memes">
|
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-4 grid-memes">
|
||||||
@foreach ($data['memes'] as $meme)
|
@foreach ($data['memes'] as $meme)
|
||||||
<div class="col mb-4">
|
<div class="col mb-4">
|
||||||
|
Loading…
Reference in New Issue
Block a user