Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call to undefined method Illuminate\Notifications\Channels\MailChannel::route()

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','[email protected]')
   ->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.

like image 883
Suraj Jeswara Avatar asked Oct 29 '25 13:10

Suraj Jeswara


1 Answers

The best way to find out where the issue is would be:


1. Go to laravel/framework on Github


2. Type the reported class into search in the top of the page

enter image description here

It fill find few results

Among others, MailChannel class


3. Scan the MailChannel class to find the right method

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

enter image description here

like image 120
Tomas Votruba Avatar answered Oct 31 '25 03:10

Tomas Votruba



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!