dimanche 1 novembre 2015

get the latest 8 records laravel 5.1

How can i get the latest 8 votes on this query by mobile number field:

results = DB::table('votes')->whereIn('votes.id', function($query){
                    $query->select(DB::raw('MAX(id) as id'))
                    ->from('votes')
                    ->groupBy('mobile_number', 'position_id','code');
                })->where(array('code'=>$code,'position_id'=>$positionId))->get();

on this query it gets the latest total votes of the users but not limited to 8.

->where(array('code'=>$code,'position_id'=>$positionId))->take(8)->get(); //it seems this is not working

Any idea? Thanks



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1ShS72R
via IFTTT

Aucun commentaire:

Enregistrer un commentaire