Support the ongoing development of Laravel.io →
posted 8 years ago
Eloquent

Hi

I have model with relation:

$u = $user->with('Articles')->first();

then i can get:

$u->articles[0];
$u->articles[1];
$u->articles[2];

Ho can i change array key of articles relation to id of the article? So i could get:

$u->articles[article_id];

Thanks in advanced!

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

altercode altercode Joined 8 Mar 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.

© 2025 Laravel.io - All rights reserved.