I am trying to get records from the database groupBy Week. I have two data start dates and end dates. Between these two dates, I want to get all the data groupBy weeks I know my below query is totally wrong. That is just for an idea
Consignment::('created_at',$request->start_date)->where('end_date',$request->end_Date)->groupBy('Week')->get();
All the results should be groupBy
weeks
Ex: week1
, week2
and etc.
if you do not have wee in column,then you need to create one during query
Consignment::addSelect(DB::raw('week(created_at) as created_at_week'))
->where('created_at',$request->start_date)
->where('end_date',$request->end_Date)
->groupBy('created_at_week')->get()