Comments (17)
No @ReeceM , I have at most 2 levels of depth in relationships 👍
Defining it in the configuration file seems to me the correct idea to avoid problems with larger applications
from laravel-mail-editor.
same problem 😢.
Any solution for this? I am also getting the same
from laravel-mail-editor.
📢 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:
- At most 2 levels deep reaction testing
- No more than one model hydrated per relation,
- possibly 2 from a config setting for things like loops
(e.g. comments)
- possibly 2 from a config setting for things like loops
- If it can't hydrate the model because there isn't a factory, it will load the Mocker object class to provide dynamic response.
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:
$user->account->plan->name
^ ^ ^ ^
| | | \ ------------------- adds to the headache, as plan is `null`
| | \ -------------------------- where the issue happens, the relation hasn't been loaded
| \ ------------------------------------- this is still okay, as the Model::class returns null
\--------------------------------------------- this is okay
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 👍
from laravel-mail-editor.
Commenting so I can follow this, and also because I'm facing a similar error, but
"Trying to get property 'email' of non-object"
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 laravel-mail-editor 1.3
into a development environment of laravel 5.8.*
EDIT: This is after install, clearing (all) cache, and going to project.dev/maileclipse
which redirects to project.dev/maileclipse/mailables
EDIT2: I can, however, get to /maileclipse/templates
, but clicking on 'new' gives me a general php error.
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
from laravel-mail-editor.
Hi, same issue like @LorenzoSapora "Trying to get property 'email' of non-object".
Laravel: 6.18.40 no fresh install -> is an existing project
There is actually no way to call the dashboard of Mail Editor.
from laravel-mail-editor.
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.
from laravel-mail-editor.
Hi @4unkur and @LorenzoSapora, are you still experiencing issues?
from laravel-mail-editor.
The whole package is unusable with this bug. Is there anyone knows how to this?
from laravel-mail-editor.
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 Model
and leave it as an undefined object type and then the variable will be given a dynamic object, this would be a temporary solution to use when you are testing the mails in the preview pane.
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? 👍
from laravel-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
from laravel-mail-editor.
Hi @ReeceM thanks for your quick reply!!
If found the issue... in my Mail Folder there are some existing Mailable and one of them trigger it.
It works, if I comment out all of the existing Mailable. Actually I'm on the way to found my issue :)
from laravel-mail-editor.
@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 Model
if it is type hinted, and then if the other is not it is a Mocked
class, this handles dynamic object calls.
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 __construct()
parameters. :)
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
from laravel-mail-editor.
same problem 😢
from laravel-mail-editor.
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?
from laravel-mail-editor.
@ReeceM commented on 5 mar 2021, 14:58 CET:
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?
Hi @ReeceM the problem is on property of relation on the model.
This is one of Mailable
with problem:
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
from laravel-mail-editor.
@BoGnY, alright, so I see that it is also from a relationship that you are calling name
property.
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 max_depth
kind of thing.
For any of the other mailable that you have there, is there anything that is deeper than a first / second level relationship call?
from laravel-mail-editor.
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 dev-fix/issue-63-loading-relations
in the composer file and run composer update
, it should require the branch and not the tagged version, obviously, this is just to test and confirm that the PR #157 does indeed fix the issue that some have faced.
You can share your issues back in here should the PR add issue for you.
from laravel-mail-editor.
Related Issues (20)
- Template preview not working? HOT 9
- Return value error on template? HOT 6
- Attempt to read property "email" on null HOT 2
- MailEclipse drops Meilisearch/Laravel scout records HOT 6
- axios.post is not a function HOT 2
- Markdown Button save > HOT 21
- Method App\Mail\RepoTestMail::build() does not exist HOT 17
- No template associated HOT 3
- Undefined variable $exception when I added variable to Mail construct HOT 6
- Edit Templates of Editor HOT 4
- Requests for each change to the template may cause performance problems and delays? HOT 6
- Major Security Vulnerability HOT 4
- Queueable trait vars HOT 1
- how can i personalice the screens of maileclipse ?? HOT 1
- Laravel 10 support? HOT 16
- Unpkg went down HOT 1
- Too few arguments to function... HOT 1
- Is it compatible with laravel 10? HOT 1
- May I know the approx. release date of new version which is supported with Laravel 10? HOT 3
- New buildMailable Implementation Fails to Invoke build Method, Breaking Edit and Preview Functionality HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-mail-editor.