-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathRankingController.php
More file actions
40 lines (34 loc) · 1.29 KB
/
RankingController.php
File metadata and controls
40 lines (34 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\View\View;
use App\Enums\CurrencyType;
use App\Models\UserSetting;
use App\Models\UserCurrency;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Cache;
class RankingController extends Controller
{
/**
* Handle the incoming request.
*/
public function __invoke(Request $request): View
{
$cacheableTime = App::isLocal() ? 0 : 300;
$rankings = Cache::remember('rankings_data', $cacheableTime, function () {
$staffIds = User::getAllStaffsId();
return [
'diamonds' => UserCurrency::getRankingFor(CurrencyType::Diamonds, $staffIds)->get(),
'respects' => UserSetting::getRanking('respects_received', $staffIds)->get(),
'duckets' => UserCurrency::getRankingFor(CurrencyType::Duckets, $staffIds)->get(),
'coins' => User::getCreditsRanking()->get(),
'points' => UserCurrency::getRankingFor(CurrencyType::Points, $staffIds)->get(),
'online-time' => UserSetting::getRanking('online_time', $staffIds)->get()
];
});
return view('pages.community.rankings.index', [
'rankings' => $rankings
]);
}
}