0
    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.

Cassey
  • 7
  • 3
  • I think your best bet would be to replace `date('Y-m-d')` by `Carbon::now()->addDays($days)` – Techno Nov 08 '22 at 15:48
  • Possible duplicate: https://stackoverflow.com/questions/57692600/add-days-to-date-in-laravel, https://stackoverflow.com/questions/46504774/laravel-how-to-add-days-to-datetime-field and https://stackoverflow.com/questions/34962735/how-to-add-number-of-days-to-a-date – OMi Shah Nov 08 '22 at 15:52
  • thanks everyone! I found the solution already :) – Cassey Nov 08 '22 at 15:55

2 Answers2

1

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 Illuminate\Support\Carbon;
Gert B.
  • 2,282
  • 18
  • 21
0
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

Gert B.
  • 2,282
  • 18
  • 21