skip to Main Content

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?

2

Answers


  1. Hello Friend Your Syntax Is Wrong The Syntax in Laravel 9.0.0 in image

    enter image description here

    Login or Signup to reply.
  2. you can write code in this syntax

    public function envelope()
    {
        return $this->view('mail.welcome') // <-- View File Name
            ->from('[email protected]')
            ->subject('Subject')
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search