Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Laravel Eloquent, group by month/year

$model->select(DB::raw('count(id) as `data`'), DB::raw("DATE_FORMAT(created_at, '%m-%Y') new_date"),  DB::raw('YEAR(created_at) year, MONTH(created_at) month'))
->groupby('year','month')
->get();
 
PREVIOUS NEXT
Tagged: #Laravel #group
ADD COMMENT
Topic
Name
6+3 =