framework
framework copied to clipboard
[12.x] Add Model::query($fetchModes) syntactic sugar
Follow-up to #54734 resp. #54443
Based on comments https://github.com/laravel/framework/pull/54734#issuecomment-2672501873 and https://github.com/laravel/framework/pull/54443#issuecomment-2644726839
You can then do
User::query([PDO::FETCH_UNIQUE])->select(['id','users.*'])->get();
without an additional call to fetchUsing()
As bert-w has pointed out, this only applies to queries created via a model's query() method (or other public methods in that chain), so it may not be an alternative for all cases.