Is there a direct way to eager load the relationships key values directly into the parent. I mean without storing it under a sub element?
for example:
$user = User::with('contact');
but instead returning this:
[
'name'=>'john',
'surname'=>'doe'
'contact' => [
'phone' => '...',
'email' => '...@...'
]
I want directly this:
[
'name'=>'george',
'surname'=>'doe',
'phone' => '...',
'email' => '...@...'
]
I could loop all users and place that value manually but I am wondering if there is a way that directly calls these from database. It would save me a lot of resource if there would be a direct way.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire