teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

誤字の修正

2020/10/11 15:36

投稿

teto277
teto277

スコア1

answer CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ```Controller
4
4
  $devices = Device::query()
5
- ->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')
6
- ->orderBy('follower_count', 'desc')
5
+ ->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')
6
+ ->orderBy('followers_count', 'desc')
7
7
  ->get();
8
8
  ```