Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 7 months 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!

LaraJobs

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.

© 2022 Laravel.io - All rights reserved.