-
-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in the README #45
Comments
The code is correct: It shows how you can use the package to combine a |
So the belongsToMany is only between User and Role; the hasManyDeep is applied to the parent level ? |
Imagine your application has these models and relationships: class User extends Model
{
public function roles()
{
return $this->belongsToMany('App\Role', 'role_user');
}
}
class Role extends Model
{
public function permissions()
{
return $this->hasMany('App\Permission');
}
} You can use this package to define a direct relationship from class User extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;
public function permissions()
{
return $this->hasManyDeep('App\Permission', ['role_user', 'App\Role']);
}
} |
Magnificent, so there is no real HasManyDeep inverse relationship in a way? |
From |
So the same hasManyDeep ? Similar to the inverse of belongsToMany, it is the same relationship ? |
It would look like this: class Permission extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;
public function users()
{
return $this->hasManyDeep(
'App\User',
['App\Role', 'role_user'],
['id'],
['role_id']
);
}
} |
Even without a pivot table ? In a case where I don't have a belongstoMany in the middle |
What's your actual relationship? |
I wanted a HasManyDeep between Mapregion and Group; Brand and Unit (using hasManyDeepFromRelations) If i wanted to get the Mapregion of a single group; since it belongs to only one; what would be the relationship ? I use your |
In this case, a |
Your packages are life-saving; for real :) Thanks! |
I think there's a typo, otherwise I didn't catch the
belongsToMany
paragraphIts written
public function permissions() { return $this->hasManyDeep('App\Permission', ['role_user', 'App\Role']); }
Shouldn't it be
public function permissions() { return $this->belongsToMany('App\Permission', ['role_user', 'App\Role']); }
?
The text was updated successfully, but these errors were encountered: