$role = 'participants';
Event::query()->with(array('users'=>function($q) use ($role){
$q->withRole($role);
};
))->get();
Or you could create a relation that directly uses this scope:
Event::query()->with('participants')->get();
In Event class:
public function participants(){
return $this->users()->withRole('participants');
}
Nice, it works. This returns an Event with an array of participants. I was thinking, if I could get the participants without the Event.
For example: Give me all the participants from the Event 1.
Thank you!
Edit
I did it :D thank you so much for help!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community