-
-
Notifications
You must be signed in to change notification settings - Fork 253
Trying to get property 'fullname' of non-object #63
Comments
Commenting so I can follow this, and also because I'm facing a similar error, but
from // vendor/laravel/framework/src/Illuminate/Mail/Mailable.php
protected function setAddress($address, $name = null, $property = 'to')
{
foreach ($this->addressesToArray($address, $name) as $recipient) {
$recipient = $this->normalizeRecipient($recipient);
$this->{$property}[] = [
'name' => $recipient->name ?? null,
'address' => $recipient->email,
];
}
return $this;
}
Fresh install EDIT: This is after install, clearing (all) cache, and going to EDIT2: I can, however, get to EDIT3: Appears to be an issue with my development environment. Not the stack, but the codebase/packages. Possibly a conflict, as I can freely use all the features in a blank 5.8 laravel install |
Hi @4unkur and @LorenzoSapora, are you still experiencing issues? |
The whole package is unusable with this bug. Is there anyone knows how to this? |
Hi @KhoaDuongUQ, the bug from what I have traced down is the fact that the relations are not loaded up. So what you could do is remove the But seems that this is still and issue and you are actively experiencing it, can you share details of the class that this affected ? Like if it is a relation that you are calling that is giving the error? 👍 |
Hi, same issue like @LorenzoSapora "Trying to get property 'email' of non-object". There is actually no way to call the dashboard of Mail Editor. |
Hi @s72817 thank you for your input. Is the class or object that the email value is being retrieved from a Model or a different class? If you would be able to share some details that can help to see what is the main cause of this |
Hi @ReeceM thanks for your quick reply!! |
@s72817 so the reason why the issue may be there is that MailEclipse generates Model classes or provides variables to the mailable so that you can preview it. There are two classes that are passed to the mailable, the one is an Eloquent So if there is a different type of class, it may be that it isn't instantiated to the correct value or that the Model class doesn't have the right things. So if you are able to when you find which Mailable is causing it, you should be able to share the Also, another thing that would be useful for your error would be the error log for when it happens, this would help to see which area it is coming from. From my reply to another user on this issue, the main thing is when it is called via a relationship, then it doesn't load unfortunately, I am trying to figure what a practical way is to hydrate any relationship models attached to the parent model |
same problem 😢 |
Hi @BoGnY sorry that you are having issues, may I ask if the value that you are calling is through a relation on the model or is it a normal class? |
@ReeceM commented on 5 mar 2021, 14:58 CET:
Hi @ReeceM the problem is on property of relation on the model. namespace App\Mail;
use App\Models\Subscription;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class SendSubscriptionPaymentReminder extends Mailable implements ShouldQueue
{
use Queueable;
use SerializesModels;
/** @var \App\Models\Subscription */
public $subscription;
/** @var string */
public $url;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(Subscription $subscription, string $url)
{
$this->subscription = $subscription;
$this->url = $url;
}
/**
* Build the message.
*/
public function build(): self
{
$this->subject(trans('mail.subscription_payment_reminder.title', ['plan_name' => $this->subscription->plan->name])); // <-- HERE THE ERROR: Attempt to read property "name" on null
return $this->view('mail.subscription-payment-reminder')
->with([
'subscription' => $this->subscription,
'url' => $this->url,
]);
}
} I'm using MailEclipse v2.2.4 with Laravel 7.30.4 |
@BoGnY, alright, so I see that it is also from a relationship that you are calling I have been trying to wrap my head around a sensible fix for this. This would make it that all the possible relations for a model need to be faked. But I am not sure the depth that it would need to go so as to be practical or sensible. It could be something that is defined in the config file, like For any of the other mailable that you have there, is there anything that is deeper than a first / second level relationship call? |
No @ReeceM , I have at most 2 levels of depth in relationships 👍 |
same problem 😢. |
📢 Just to provide some feedback. 📢 I have had some time to test out the idea I had to be able to detect/guess relations that are on models, as this is where the issue comes in, and to try and initialize those relations as well. Through testing, the initial method is lending itself to limiting the total number of relations searched to at most 2, this is because to actual do it further would result in longer response time. What will be available I am thinking then is this:
The reason for number 3 is the case where someone might have a relation, but because the package uses factories to create a new model instance, if it isn't there usually it provides the blank instance. If someone is calling a relation like below:
Then with the changes, hopefully the account will be a valid relation, the plan will also be, but name will have to be based on the plan. At that point, my earlier comment of allowing a config to be set for the number of relations would have to come into effect for certain use cases. #63 (comment) Please feel free to share a GH reaction to give some feedback 👍 |
Hi all that have commented on the issue or had this issue, I would like to see if those who had the issue are able to make use of the branch version to test in their Laravel apps. You can spin up a new Laravel app or try it in one that already has MailEclipse installed , you can change the version to You can share your issues back in here should the PR add issue for you. |
Hi all, we are happy to note that the versions 3.4 and 2.3 each have a fix for this issue. Thank you all for being patient for the fix and also for initially raising the issue and providing more information about it so that it could be sorted out. Please feel free to open a new issue should there be bugs for it. |
I have seen that similar issues have been already submitted & resolved, but I was not able to find a clear explanation what I have to do in order to fix this issue. I have MailEclipse version 1.3 installed
There is a
ProductCreated
mailable &product-created.blade.php
markdown template. In that template file I have the following line:Mailable class:
Please assist. Thanks.
The text was updated successfully, but these errors were encountered: