laravel with relation relation code example
Example 1: laravel where on relation
Event::whereHas('participants', function ($query) {
$query->where('IDUser', '=', 1);
})->get();
Example 2: laravel relation of relation
//Multiple relationships:
$books = Book::with('author', 'publisher')->get();
//Nested relationships:
$books = Book::with('author.contacts')->get();