Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

How to write this query in Laravel Eloquent

Visitor::select('country')
     ->withCount('id')
     ->groupBy('country')
     ->latest()
     ->get()
  
  //or
  
  Visitor::query()->groupBy('country')->orderByDesc('count')->select('country' ,DB::raw('COUNT(1) as count'))->get()
Source by laravel.com #
 
PREVIOUS NEXT
Tagged: #How #write #query #Laravel #Eloquent
ADD COMMENT
Topic
Name
4+7 =