Closed nickbluestone98 closed 3 years ago
Coincidentally I ran into the same thing today. I used a quick workaround by extending the SendMail action by my own and overwriting the handle method.
I agree that a more granular level of control here might be nice
Cheers for the reply, I only needed to use this package in one other Model for the time being so it was quicker to add an email field.
I certainly think this would be a good thing to be made possible in a later release and not too much of an ask.
For those who are in the same situation, my solution was:
public function getEmailAttribute (): string
{
return $this->user->email;
}
public function getEmailField(): string
{
return 'email';
}
I think the solution from @wendelyleal is best and was the original intent. It still allows for as much freedom as you want at the cost of just having to add an additional attribute to your model.
I'm open to suggestions though if anyone has other ways that are just as flexible!
Closing this due to inactivity. This is still the intended way to access attributes from related models to the mailable model.
Rather than needing to make an email field in every single model you want to use the action on is there a way to use an email field from an eloquent relation?