laravel eloquent where relation is code example
Example 1: laravel where on relation
Event::whereHas('participants', function ($query) {
$query->where('IDUser', '=', 1);
})->get();
Example 2: eloquent relationships
$roles = App\User::find(1)->roles()->orderBy('name')->get();