Support the ongoing development of Laravel.io →
posted 9 years ago
Database
Last updated 1 year ago.
0

Are you missing a collectable or collectables class?

Last updated 9 years ago.
0

I don't have a collectable or collectables class, but then what would be the relationship between the collectable class and all other classes?

0

Okay, the problem was not the way the I modeled the relationships... Somehow

Animal::find(2)->first()->id; // returns 1

always returns a DB row with ID 1 instead of a DB row with ID $key. I'm still puzzled why, because

Animal::where('id', 2)->first()->id; // return 2

So, technically this issue is solved and will mark it as solved, but I still can't explain this behavior.

EDIT: Okay, after digging around in the Laravel code, the find() method already uses the first() method and thus a second first() method after find() will screw up the result. "Mystery" solved...

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

gamer13 gamer13 Joined 7 Aug 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.