【发布时间】:2021-08-12 03:41:15
【问题描述】:
我需要按点获取当前用户排名。例子。我按以下方式计算所有用户总数:
$userCount = User::count();
我有带有点列的用户表。 USERS 表:
USER ID | USERNAME | POINTS
1 USERA 32.25
2 USERB 2.25
3 USERC -12.25
我需要根据他的分数来获得选定的用户排名。
更新: 我的刀片显示用户个人资料:
public function show($slug)
{
/** @var User $user */
$user = User::whereSlug($slug)->firstOrFail();
if (! $user->isActivated()) {
$this->alertInfo(trans('app.access_denied'));
return;
}
$user->access_counter++;
$user->save();
$this->title("Player $user->username profile");
$this->pageView('users::show', compact('user'));
}
路线文件:
ModuleRoute::context('Users');
ModuleRoute::resource('users', 'UsersController', ['only' => ['index', 'show', 'edit', 'update']]);
ModuleRoute::get('players/{slug}', 'UsersController@show')->name('users.show');
【问题讨论】: