title: pass variable from Laravel mailable class to view
body: <p>I need to pass user object and a password to Laravel mailable class. I've tried so many ways, nothings seems to work. Here's my latest attempt.</p>
  
  <p>Password is passed into payload properly.</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>Mail::to($user)
              -&gt;queue(new EmployeeCreated($password));
  </code></pre>
  
  <p><strong>Mailable</strong></p>
  
  <pre><code>class EmployeeCreated extends Mailable
  {
      use Queueable, SerializesModels;
  
      public $password;
  
      /**
       * Create a new message instance.
       *
       * @return void
       */
      public function __construct($password)
      {
          $this-&gt;password = $password;
          $password = $password;
      }
  
      /**
       * Build the message.
       *
       * @return $this
       */
      public function build()
      {
          return $this
              -&gt;subject('YOU ARE IN!')
              -&gt;view('mail.employees.created')
              -&gt;withPassword($password);
      }
  }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>You got your account. Got to {{url('/login')}}. Use e-mail as username. Your password is {{$password}}.
  </code></pre>
  
  <p><strong>Error message</strong></p>
  
  <pre><code>ErrorException: Undefined variable: password in /var/www/html/storage/framework/views/4c04e63464617b1ec451525800e71aa14d7540d4.php:1
  </code></pre>