I\'m developing a web API with Laravel 5.0 but I\'m not sure about a specific query I\'m trying to build.
My classes are as follows:
class Event exte
The correct syntax to do this on your relations is:
Event::whereHas('participants', function ($query) { return $query->where('IDUser', '=', 1); })->get();
Read more at https://laravel.com/docs/5.8/eloquent-relationships#eager-loading