PHP-089 / 中級
Eloquent のネスト関連ロードによる N+1・DoS
なぜ問題になるのか?
リクエストパラメータでロード深度を決めると多数のクエリが発生します。
修正方法
php
$allowed = ['posts', 'profile'];
User::with(array_intersect((array) $request->input('relations'), $allowed))->get();