I’m getting this error in Laravel while trying to get from route method. My error is:
Symfony Component Debug Exception FatalThrowableError
(E_ERROR) Class ‘NewUserWelcomeMail’ not found
My route method is:
JavaScript
x
Route::get('/email', function() {
return new NewUserWelcomeMail();
});
NewUserWelcomeMail class code is:
JavaScript
<?php
namespace AppMail;
use IlluminateBusQueueable;
use IlluminateMailMailable;
use IlluminateQueueSerializesModels;
use IlluminateContractsQueueShouldQueue;
class NewUserWelcomeMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('emails.welcome-email');
}
}
I tried this as this video said but don’t understand why my one is not working as all rest are working fine. Video time from 4:13:00.
Advertisement
Answer
You need to specify the namespace. Change your route code to the following:
JavaScript
Route::get('/email', function() {
return new AppMailNewUserWelcomeMail();
});