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

It looks to me that you really need a belongsToMany() with some extra consideration for the user_role property, something like:

public function projects()
{
    return $this->belongsToMany('Project')->withPivot('user_role');
}

hasManyThrough() is just shortcut for jumping across two One-to-Many relationships. For example, a User has many Posts and a Post has many Comments. You could set up a hasManyThrough() relationship to see all of the Comments made on all Posts by a User.

Hope this helps.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

steve3d steve3d Joined 21 May 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.

© 2024 Laravel.io - All rights reserved.