Hi I want to order the set of records by month in laravel 5. The problem is when I use order by 'Month', it just ordered the records by alphabets like (apr, aug, dec, feb, jan, jul, jun, may..). But what I want is something like this (jan,feb,mar,apr,may,jun,jul,aug). It should order by upcoming months. Given below is my code:
public static function getMonths($customer_id = false)
{
$customer = DB::table('customer');
$customer->join('customer_month_calender','customer_month_calender.customer_id','=','customer.id','left');
$customer->select('customer.id','customer.name','customer_month_calender.month');
$customer->orderBy(DB::raw('MONTHNAME(customer_month_calender.month)'), 'asc');
$customer->groupBy('customer.id');
return $customer->get();
}
Can anyone please help me with this?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1NzKlU9
via IFTTT
Aucun commentaire:
Enregistrer un commentaire