firstOrCreate()->first() ? #33333
Answered
by
netpok
foremtehan
asked this question in
General
-
Guys I mistakenly put Person::query()->firstOrCreate(['name' => 'alex']);
Person::query()->firstOrCreate(['name' => 'john'])->first(); // returns alex! |
Beta Was this translation helpful? Give feedback.
Answered by
netpok
Jun 25, 2020
Replies: 1 comment
-
It is, you're calling a non existing method on a model so it will be passed to the builder. It is basically the same as calling:
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
foremtehan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is, you're calling a non existing method on a model so it will be passed to the builder. It is basically the same as calling:
Person::first()
or(new Person())->first()