orderBy('date', 'DESC') ->get([ DB::raw('Date(created_at) as date') ])->pluck('date'); $queriedDate = $request->get('date'); if(!$queriedDate) { $queriedDate = $dates->first(); } $constellations = Constellation::whereDate('created_at', $queriedDate)->get(); return view('constellations')->with([ 'dates' => $dates, 'queriedDate' => $queriedDate, 'constellations' => $constellations ]); } }