title: Passing parameters when writing a callback function in php (Laravel 5)
body: <p>I'm programming in php using Laravel 5. I have this code.</p>
  
  <pre><code>    $newUser = $this-&gt;create($request-&gt;all());
      $newUser-&gt;save();
  
      $newAccount = new Account(['user_id' =&gt; $newUser-&gt;getAttribute('id')]);
      $newAccount-&gt;save();
  
      Mail::send('emails.welcome', ['username' =&gt; $newUser-&gt;name, 'active_token' =&gt; $newUser-&gt;active_token], function($message)
      {
          $message-&gt;to($newUser-&gt;email, $newUser-&gt;name)-&gt;subject('Welcome');
      });
  </code></pre>
  
  <p>The problem here is that I don't know how to pass the "newUser" variable within the callback function. It is not working because of the scope. So, how can I pass parameters when writing a callback function? in order to use them inside that scope?</p>
  
  <p>Thank you</p>