skip to Main Content
    public function doctorToday(Request $request){
        $doctors = Appointment::with('doctor')->whereDate('date',date('Y-m-d'))->get();
        return $doctors;

May I know how to implement one more day to the code? I want to get the tommorow’s date instead of today’s.

2

Answers


  1. public function doctorToday(Request $request){
            $doctors = Appointment::with('doctor')->whereDate('date',date('Y-m-d', strtotime('+1 days')))->get();
            return $doctors;
    

    you need to add strtotime(‘+1 days’)

    this should work

    Login or Signup to reply.
  2. I would suggest using Carbon instead of date().

    public function doctorToday(Request $request){
        $doctors = Appointment::with('doctor')->whereDate('date',Carbon::now()->addDay()->format('Y-m-d'))->get();
        return $doctors;
    

    don’t forget to add the use statement at the start of the class:

    use IlluminateSupportCarbon;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search