-
-
Notifications
You must be signed in to change notification settings - Fork 261
[Constructor error] Fatal error when using package #1
Comments
Where does the MailClass come from? Seems like a Class that is created by you, Can't find them in Laravel default Package.... |
MailClass is the name I changed because of security of my application. Lets take another example to be more clear;
|
Ok, my fault. Did not recognize that your expample shows a mailable Class 🤦♂️ In my App, i have similar use cases with Mailables, where an user or order is passed as Parameter to the Constructor or the Mailable. |
I'll install it in a second again to debug it somewhat further. (I do not have really that much of complicated mailable classes but it seems to get stuck there) |
I think I know what is going wrong. Just installed it again, and went to line 548 in the mailEclipse.php class. I saw this piece of code:
And my mailable classes actually accept some constructor options that are not passed in in this piece of code. Thats why it is failing. Is this ment to be installed in a new Laravel installation, or could it also be used in a already-existing application? |
@Cannonb4ll Thanks for opening the first issue! I would be thankful if you share the mailable class |
Sure @Qoraiche:
|
Same problem here: class CancelApprovalRound extends Mailable
{
use Queueable, SerializesModels;
public $project_file;
public $project;
/**
* Create a new message instance.
*/
public function __construct(ProjectFile $project_file)
{
$this->project_file = $project_file;
$this->project = $this->project_file->Project;
}
|
Yes, I can confirm its because there are no variables passed to the constructor. I would try to read out which types are passed in the constructor and pass them. In case of a Model you could actually do for example |
@fridzema @Cannonb4ll yes thank you, I'm working now to fix this issue. |
Maybe an option is to define an Interface that should be implemented by the mailable class that is editable. So the developer can decide which data should be delivered to create an instance... Interfance
Mailable:
mailEclipse.php
|
@biwerr I'm not feeling lucky enough to be editing 50+ mailable classes to make it work with this package. Seems not generic enough; idea is good though. I would rather have it guess the constructor types and pass in. |
@Cannonb4ll, @biwerr, @fridzema error fixed, check out this commit 536bf7e. |
Did you want me to install it as 'dev-master' because I noticed you did not release a new version? Anyhow, I did that, we got a little bit further now, I am now getting this error:
foreach ($args->all() as $arg) {
if ( is_array($arg) ){
$filteredparams[] = new $arg['instance']; <--- Fails here
continue;
}
$filteredparams[] = $arg;
} This is because I have a mailable class that accepts a string too. Example: class WelcomeEmail extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
public $user;
public $message;
/**
* Create a new message instance.
*
* @param \App\Models\User $user
*/
public function __construct(User $user, $message = '')
{
$this->user = $user;
$this-message = $message;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this
->subject('Welcome!')
->markdown('emails.user.welcome');
}
} |
Hmmm the error is gone, but i think this package can't work for me easily.
If i surround all those in I think if i edit all mailables it should work, but don't have the time to do it right now. |
Check out this commit fdabb35, pre-release (v1.1.0-alpha)
@fridzema, @Cannonb4ll, @biwerr i will be thankful if you confirm with your mailables. Thanks again! |
This issue is still in v3.5.1 i.e latest release. I tried with Laravel framework v8.40 and it returns the same error. I even try with |
Hi @sachinkumar121, thank you for highlighting this. Would it be possible to provide more detail? As I have found usually this is because the constructor is using a class sometimes that cannot be created. If you can provide a error message and a reproduction it would be great. |
Sure @ReeceM. I would like to share two issues. Earlier, it gives the error of But if you create a new model by using the artisan command( So by mistake, if we use any model whose factory class is not defined then it throws an error of Anyway, the second issue is about __construct parameters. It gives the following error with my current configuration.
composer.json
SslNotInstalledMail.php
|
After 3 hours of investigation, I come to know the real reason behind this issue. in my case the maileclipse's config's factory value is true. so all the conditions of the resolveFactory function of the MailEclipse model never pass because I don't have a factory class associated with my Model. laravel-mail-editor/src/MailEclipse.php Lines 913 to 932 in 5871e9e
So it is returning the null and the model reference parameter in the __construct method didn't pass. Suggestions:- The error returned by package should be more relevant and mention that as you set the factory
and also on Github readme.MD file there should be full information about the factory config value. |
Hi @sachinkumar121 I’ll reopen this for now, will have a look later. But in the meantime if you would like to, you are welcome to PR an exception/warning for the missing factories. |
Hi @blackcore003 is this after the package has been installed? Are you able to provide more information? This may need to be a new issue rather. |
Run |
There seems to be more of a namespace issue in the package on the v2 branch. Also running the I am just busy at the moment and will have a look later. |
Hi @blackcore003 please could you run Please can you comment in the linked issue below #204 please, this is a separate issue ti this one here |
First off; looks pretty awesome. I wanted to give it a run in my application (which has a lot of mailables), but straight away I get an error when I visit /maileclipse:
The constructor of this class has 3 arguments available:
I would debug it myself and PR it if I had the time. Still thanks for such a great package 👍
The text was updated successfully, but these errors were encountered: