title: Laravel4 ->whereIn: get all keywords per event
body: <p>I have the following query: </p>
  
  <pre><code>public function getEventsByKeywordIds($data){ 
      //Query events by dates 
      $query = DB::table('events')
                  -&gt;join('events_dates', function($join) use ($data){
                      $join-&gt;on('events.id', '=', 'events_dates.event_id')
                              -&gt;where('events_dates.start_date', "&lt;=", date_format(date_create($data['date_end']), "Y-m-d"))
                              -&gt;where('events_dates.end_date', '&gt;=', date_format(date_create($data['date_start']), "Y-m-d")); 
                  }); 
      //Query events by keywords 
      $query = $query-&gt;join('events_keywords', function($join) use ($data){ 
                      $join-&gt;on('events.id', '=', 'events_keywords.event_id'); 
                  })-&gt;whereIn('events_keywords.keyword_id', $data["keyword_ids"]); 
  
      //Query places 
      $query = $query-&gt;join('places', function($join) use ($data){ 
                      $join-&gt;on('events.place_id', '=', 'places.id'); 
                  }); 
      //Set offset and limit 
      $query = $query
              -&gt;take($data['limit'])
              -&gt;offset($data['offset'])
              -&gt;orderBy('events_dates.start_date', 'ASC')
              -&gt;orderBy('events.name', 'ASC')
              -&gt;groupBy('events.id'); 
  
     $events = $query-&gt;get(); 
     return $events; 
  } 
  </code></pre>
  
  <p>I am interested in the part that mentions "Query events by keywords".  </p>
  
  <p><code>events_keywords</code>is a many-to-many table, linking event id's and keyword id's to each other.  </p>
  
  <p>The requirement exists to return <strong>the keywords per event</strong> to the client, but so far the query only returns 1 keyword per event that it returns.<br>
  Note: <code>$data["keyword_ids"]</code>is an array of keywords sent from the client, because only events related to certain keywords should be returned.  </p>
  
  <p>Do you have any suggestions to adapt this query in a simple way to meet the requirement?  </p>
  
  <p>Edit: what I require is actually the keyword names, which is stored in the keyword table (not the many-to-many. </p>