This is really strange. I have a laravel app where I use the module library
https://github.com/nWidart/laravel-modules
I don’t know if it has with the issue to do, but just want to point it out.
Basically, I am writing phpunit tests. The first test is calling an endpoint. In that case, the controller will call a repository class(basically a php-class inside the folder "Repositories", nothing stranger than that) which in turn calls
Mail::queue(new MyFirstMail($arg));
Well, this works. And I can also have a chech in the test to verify the mail has been queued:
Mail::assertQueued(MyFirstMail::class, 1);
The second test, instead, is calling an artisan command, this way:
$this->artisan('a_command_job');
This will basically run the method "handle" inside a class that is located at "Modules/Console/Commands/MyCommand.php"
From inside that handle method, I will call this:
Mail::queue(new MySecondMail($arg));
This test fails. The error is
View [emails.second_email] not found
MySecondMail.php is a class that extends "BaseMail". Which is the same for MyFirstMail.php.
They look more or less exactly the same. Of course they include two different views.
MyFirstMail has no problem in including the view. While MySecondMail cannot find the view.
I also tried by passing the same view name for MySecondMail. But I still get the same error.
I suspect that this has to do with the fact that the first one is triggered by a call to an endpoint. While the second one is called by an artisan command. But I really don’t understand how to make MySecondMail to pick up the right path to the view. I also have tried with "base_path". But it did not work and Im not sure it is the right way to do it.
2
Answers
Add this in front of Mail
For example
Check your view folder if you have a blade file called second_mail.blade.php under emails folder
Else create the blade file