Please read about many to many relationships, it explains what you're asking: https://laravel.com/docs/5.7/eloquent-relationships#many-to-many
Also pay attention to how the tables are named. Your "UserRights" table should be 'right_user'. If you don't follow eloquent naming conventions, you will have more trouble and have to use more code to make things work. https://laravel.com/docs/5.7/eloquent#eloquent-model-conventions
users
--------
-id
-other fields
rights
--------
-id
-name (or something)
-other fields
right_user
---------------
-user_id
-right_id
Then in User model
public function rights() {
return $this->belongsToMany(App\Right::class);
}
and in Right model
public function users() {
return $this->belongsToMany(App\User::class);
}
Then use something like
$users = User::with('rights')->get();
foreach ($users as $user) {
foreach ($user->rights as $right) {
echo $right->name;
}
}