kirschbaum-development / nova-mail

A Laravel Nova action that provides a mail sending form for any resource
MIT License
73 stars 25 forks source link

Provide more than 1 address from relations via getEmailField() #25

Closed 4n70w4 closed 3 years ago

4n70w4 commented 5 years ago

For example, email addresses for model provides via chain of relations organization->contacts->pluck("email")

This don't works:

    public function getEmailField(): string
    {
        return 'organization->contacts->pluck("email")';
    }

Okay, I add:

    public function getEmailsAttribute() {
        return $this->organization->contacts->pluck('email')->toArray();
    }

and use:

    public function getEmailField(): string
    {
        return 'emails';
    }

But new error:

{
    "message": "Argument 4 passed to KirschbaumDevelopment\\NovaMail\\Mail\\Send::__construct() must be of the type string, array given, called in /var/www/app/vendor/kirschbaum-development/nova-mail/src/Actions/SendMail.php on line 37",
    "exception": "Symfony\\Component\\Debug\\Exception\\FatalThrowableError",
    "file": "/var/www/app/vendor/kirschbaum-development/nova-mail/src/Mail/Send.php",
    "line": 43,
michaelfox commented 4 years ago

Hi @4n70w4! Thanks for the feedback on this issue. We've been busy but are hoping to carve some time out soon.

adammparker commented 3 years ago

Solved with the latest release - https://github.com/kirschbaum-development/nova-mail/releases/tag/1.0.2

Thanks!