Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[5.4] Add whereKey method #16558

Merged
merged 2 commits into from
Nov 26, 2016
Merged

[5.4] Add whereKey method #16558

merged 2 commits into from
Nov 26, 2016

Conversation

mnabialek
Copy link
Contributor

This method will make easier to add condition with primary key (what is not always id). It is also useful when you want to get one column only. For example instead of:

return ($model = Model::find(1)) ? $model->value('name') : null;

or

return $model->where('this_is_key_name',1)->value('name');

you can use:

return $model->whereKey(1)->value('name');

This is breaking change (all occurrences of whereKey( method in existing app should be changed to where('key', so it's in 5.4 as agreed in #16540

@taylorotwell taylorotwell merged commit 7b54ffa into laravel:master Nov 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants