Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Laravel query child from parent whereHas

// Querying child relation "GamePlayer" with a condition
$gameList = Game::with(['GamePlayer','Category:id,name'])
         ->whereHas('GamePlayer', function ($q) use ($playerId) {
                      $q->where('player_id', $playerId);
   })->get();
 
PREVIOUS NEXT
Tagged: #Laravel #query #child #parent #whereHas
ADD COMMENT
Topic
Name
4+2 =