Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dilfdo's avatar

List most latest data according to date coloumn and time coloum

here is my controller , i want to list the recordes latest first according to the date and time field


   public function index()
    {
        //
        if (Auth::check()) {

//            $PhoneBookings = PhoneBooking::all();
            $PhoneBookings = PhoneBooking::orderBy('date','time', 'DESC')->get();
            return view('booking.listBooking', compact('PhoneBookings'));
        }
        else{
            return view('auth.login');
        }
    }

please advice

0 likes
1 reply
abhimanyusharma003's avatar

Can't say it's the best method but will work

PhoneBooking::latest('date')->latest('time')->get();

Please or to participate in this conversation.