mardi 22 janvier 2019

Laravel - How to group by data and fetch last data that has been inserted

I want to group this data i have, everytime i do the groupby clause , it does not group. kindly help thanks here is my controller code which has the group clause also, I want to fetch the last data when the data is grouped.

public function showTime(Request $request, $id)
{
    $employee = Employeefm::find($id);


    $search = $request->get('search');
    $employeeSched = DB::table('schedules')->where('employee_no','like', '%'.$search.'%')->paginate(10);


    $employeeSched = DB::table('schedules')
    ->select('date_today')
    ->groupBy('date_today')
    ->get();

    return view('admin.employeemaintenance.showTime',compact('employee','employeeSched'));
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire