Support the ongoing development of Laravel.io →
posted 9 years ago
Eloquent
Last updated 2 years ago.
0

You're doing it wrong. Your code is inconsistent, that's the reason:

$model = Model::with('someRelation')->first();
// 'someRelation' stored in relations array

$model->some_relation; // new query, new 'some_relation' stored in relations array

// but try camelCased and it will be what you expect
$model->someRelation
0

Ooohhh, of course! So when I ->toArray(), 'someRelation' (ie camelCases) renames to 'some_relation' (ie underscored).

should have realised. Welp, wont be doing that again. Thanks for your help :D

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Towerful towerful Joined 4 Jan 2015

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.