Home > Back-end >  Laravel Mail - New methods with interesting parameter passing
Laravel Mail - New methods with interesting parameter passing

Time:12-03

I am wondering here by the parameter passing in the new Laravel Mail class. My IDE (VSCode) also underlines the parameter and throws the following error: syntax error, unexpected ':', expecting ')'

public function envelope()
{
    return new Envelope(
        subject: 'Subject', // <-- the key subject
        from: '[email protected]', // <-- the key from
    );
}

Nevertheless, it works. It's probably a new PHP specification that I don't know yet. What is it called and does it work? And how can I teach my IDE that it is not an error?

CodePudding user response:

Hello Friend Your Syntax Is Wrong The Syntax in Laravel 9.0.0 in image
enter image description here

CodePudding user response:

you can write code in this syntax

public function envelope()
{
        return $this->view('mail.welcome') // <-- View File Name
        ->from('[email protected]')
        ->subject('Subject')
}
  • Related