Level 88
You can probably do something like this
$data = User::with('city')
->withCount('point')
->orderByDesc('points_count')
->get();
$data = $data->where('points_count', '>' 0);
$data->map(function ($user, $key) {
$user->ranking = $key + 1;
return $user;
});
Documentation: https://laravel.com/docs/7.x/collections#method-map
In your resource, you should have the extra key available now
return [
// Other fields
'ranking' => $this->ranking,
];