Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TheAkashRajput's avatar

Laravel Eloquent conditional relations and Entrust Roles mapping?

I'm able to map relation like this with a Role column in users table:

public function members(){

return $this->hasMany('App\User')->whereRole('member');

}

But for multiple roles for single user I want to do it something like this with Entrust:

public function members(){

return $this->hasMany('App\User')->joinWith('role_users')->whereRole('member');

}

I'm working on a complex system. I really need this done is there a way to map the multiple roles with users with conditional relations.

0 likes
0 replies

Please or to participate in this conversation.