$movies = Movie::whereHas('director', function($q) {     $q->where('name', 'great'); })->get(); 

Read more of this post