Hi i got this error message "Call to a member function delay() on null"
this is my code in contoller
$input = $request->end_date;
$format = 'd/m/Y';
$date = Carbon::createFromFormat($format, $input)->toDateString();
$when = Carbon::parse($date)->subDays(7);
$this->dispatch(
$request->user()->notify(new EndDate($asset))->delay($when)
);
I have no idea how to fix that, I'm new in programming, so I hope someone could help me to fix this error.
You were close!
The delay method should be called on the EndDate
notification and not chained on after the notify()
method.
Also, you shouldn't need to use $this->dispatch()
as the notify()
method will do this for you.
$request->user()->notify((new EndDate($asset))->delay($when));
Below is the exact same code, however, I've just broken it on to multiple lines to make it clearer and easier to see:
$request->user()->notify(
(new EndDate($asset))->delay($when)
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With