title: Cannot unpack array with string keys - passing multiple non-model data to mail view
body: <p>I am trying to pass non-model data to my email blade. I however keep getting this error.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>Cannot unpack array with string keys</code></pre>
  </div>
  </div>
  </p>
  <p>I have tried using the following <a href="https://stackoverflow.com/questions/40663687/cannot-unpack-array-with-string-keys">post</a> but didn't get to resolve the issue I am having.</p>
  <p>Here is my controller:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$data = ['email'=&gt; $email, 'token'=&gt; $token, 'name'=&gt; $name];
          sendMailWithMailerClass($email, '\App\Mail\ApplicantSetPasswordMail', $data);
          
  ...
  
  
  
  function sendMailWithMailerClass($mailTo, $mailerClass, $mailerClassParams)
  {
    
      try{
          Mail::to($mailTo)-&gt;send(new $mailerClass(...$mailerClassParams));
      } catch (Exception $e) {
         
      }
  }</code></pre>
  </div>
  </div>
  
  The email class is here below</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;?php
  
  namespace App\Mail;
  
  use Illuminate\Bus\Queueable;
  use Illuminate\Mail\Mailable;
  use Illuminate\Queue\SerializesModels;
  use Illuminate\Contracts\Queue\ShouldQueue;
  
  class ApplicantSetPasswordMail extends Mailable
  {
      use Queueable, SerializesModels;
      public $data;
  
      
      public function __construct($data)
      {
          $this-&gt;data = $data;
      }
  
      
      public function build()
      {
          return $this-&gt;markdown('emails.applicant_set_password', compact('data'));
      }
  }</code></pre>
  </div>
  </div>
  </p>
  <p>Here is my email view:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en" &gt;
  &lt;head&gt;
  &lt;/head&gt;
  
  &lt;body &gt;
  &lt;center&gt;
      
      &lt;p&gt;Dear {{ $data['name'] }},&lt;/p&gt;
      &lt;p style="margin-bottom: 25px;"&gt;Text&lt;/p&gt;
      &lt;a href="{{ URL::to('/').'/url/?email='.$data['email'].'&amp;token='.$data['token'] }}" &gt;Set Password&lt;/a&gt;
                       
  &lt;/center&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>