[api] fix user torrent stat

This commit is contained in:
xiaomlove
2022-02-21 18:04:46 +08:00
parent 2fc4f0e5b9
commit ab7b2d506b

View File

@@ -197,9 +197,10 @@ class UserController extends Controller
private function getUserProfile($id)
{
$user = User::query()->withCount([
'comments', 'posts', 'torrents', 'seeding_torrents', 'leeching_torrents',
'completed_torrents' => function ($query) use ($id) {$query->where('snatched.userid', '!=', $id);},
'incomplete_torrents' => function ($query) use ($id) {$query->where('snatched.userid', '!=', $id);},
'comments', 'posts', 'seeding_torrents', 'leeching_torrents',
'torrents' => function ($query) use ($id) {$query->whereHas('snatches');},
'completed_torrents' => function ($query) use ($id) {$query->where('torrents.owner', '!=', $id);},
'incomplete_torrents' => function ($query) use ($id) {$query->where('torrents.owner', '!=', $id);},
])->findOrFail($id);
$resource = new UserResource($user);
return $resource;