Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[12.x] Add Model::query($fetchModes) syntactic sugar #54745

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

shaedrich
Copy link
Contributor

@shaedrich shaedrich commented Feb 21, 2025

Follow-up to #54734 resp. #54443

Based on comments #54734 (comment) and #54443 (comment)

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.

* @return \Illuminate\Database\Eloquent\Builder<static>
*/
public static function query()
public static function query(?array $fetchModes = [])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ?array?
Can it be null?

* @return \Illuminate\Database\Eloquent\Builder<static>
*/
public function newModelQuery()
public function newModelQuery(?array $fetchModes = [])
Copy link

@macropay-solutions macropay-solutions Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change that was avoided in @bert-w 's PR.
We think that PR was ok just that it deleted a function that generated a bug and so the whole feature was reverted.

@shaedrich shaedrich marked this pull request as draft February 21, 2025 20:50
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants