laravel where on relation
snippet in php

laravel where on relation

user4963

Event::whereHas('participants', function ($query) {
    $query->where('IDUser', '=', 1);
})->get();

how to use where relationship laravel

user5487

Event::with(["owner", "participants" => function($q) use($someId){
    $q->where('participants.IdUser', '=', 1);
    //$q->where('some other field', $someId);
}])