回答編集履歴

1

誤字の修正

2020/10/11 15:36

投稿

teto277
teto277

スコア1

test CHANGED
@@ -6,9 +6,9 @@
6
6
 
7
7
  $devices = Device::query()
8
8
 
9
- ->selectRaw('devices.*, (select count(*) from users inner join device_follow on users.id = device_follow.user_id inner join game_follow on users.id = game_follow.user_id where devices.id = device_follow.device_id and game_follow.game_id = 1) as followers_count')
9
+ ->selectRaw('devices.*, (select count(*) from users inner join device_follow on users.id = device_follow.user_id inner join game_follow on users.id = game_follow.user_id where devices.id = device_follow.device_id and game_follow.game_id = '.$game->id.') as followers_count')
10
10
 
11
- ->orderBy('follower_count', 'desc')
11
+ ->orderBy('followers_count', 'desc')
12
12
 
13
13
  ->get();
14
14