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

Have you tried belongsTo instead? I'm assuming this a one-to-one relationship.

0

ddimaria said:

Have you tried belongsTo instead? I'm assuming this a one-to-one relationship.

No, more than one account can have the same type, so it's not one-to-one.

0

try

public function type() {
    return belongsTo('App\\AccountType', 'account_id', 'id');
}

and access it by

{{ $user->type->web_descr }}
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.