title: Laravel: send user name on email
body: <p>So my email functionality can send emails to users. However i want to be able to send emails with the username that they enter when they register. For example 'Hello "john" ' in which john is the name entered. I have the following code:</p>
  
  <p>RegisterController.php:</p>
  
  <pre><code>    protected function create(array $data)
  {
      Mail::to($data['email'])-&gt;send(new WelcomeMail());
      return User::create([
          'name' =&gt; $data['name'],
          'email' =&gt; $data['email'],
          'password' =&gt; Hash::make($data['password']),
      ]);
  
  }
  }
  </code></pre>
  
  <p>Welcome.blade.php</p>
  
  <pre><code>@component('mail::message')
  
  Welcome to the Hotel Booking System {{$data-&gt;name}}
  
   The body of your message.
  
  
  
    Thanks,&lt;br&gt;
      {{ config('app.name') }}
  @endcomponent
  </code></pre>
  
  <p>Now in the welcome.blade.php is where i am receiving the error message of Undefined Variable $name. How would i fix this using the two pieces of code. </p>