I am trying to send notification to a particular mail id and is using the following code in my controller:
$product=Product::first();
Notification::route('mail','suraj@yahoo.com')
->notify(new NewProducts($product));
But I get an error
Call to undefined method Illuminate\Notifications\Channels\MailChannel::route()
.
All prerequisites are being added and I even successfully sent a mail when i used an object of my User model. I came across this process in laravel doc5.3.
The best way to find out where the issue is would be:
It fill find few results
Among others, MailChannel
class
MailChannel
class to find the right methodJust looking at class, you'll quickly find send()
method, that does what you want. As suggested by @Suraj
All this work can be automated nowadays by using IDE - smart software editor. From my 5+ years experience I recommend PHPStorm, but you can use any.
Why?
It does all 4 steps above right in your browser. Tells you what methods are available on all classes.