O'Reilly logo
  • GIL EG thinks this is interesting:

 $authorsWithABookFromThe1864 = \App\Author::whereHas('books', function($q)
  {
      $q->where('year', '=', 1864);

  })->get()

From

Cover of Learning Laravel's Eloquent

Note

Related model whereHas