laravel with relationship where code example
Example 1: laravel where on relation
Event::whereHas('participants', function ($query) {
$query->where('IDUser', '=', 1);
})->get();
Example 2: laravel load relation on a relation
$books = Book::with('author.contacts')->get();
Example 3: eloquent relationships
$roles = App\User::find(1)->roles()->orderBy('name')->get();