use relation data inside where clause laravel code example
Example: laravel where on relation
Event::whereHas('participants', function ($query) {
$query->where('IDUser', '=', 1);
})->get();
Event::whereHas('participants', function ($query) {
$query->where('IDUser', '=', 1);
})->get();