title: Laravel Email Confirmation On Registration
body: <p>I need to send an email after a new user is created.</p>
  
  <p>But I don't know how to return to the home page without getting an error.
  This is what I am doing right now.</p>
  
  <pre><code>User::create([
              'name' =&gt; $data['name'],
              'username' =&gt; $data['username'],
              'email' =&gt; $data['email'],
              'password' =&gt; bcrypt($data['password']),
              'phone' =&gt; bcrypt($data['phone']),
              'confirmation_code' =&gt; str_random(30),
          ]);
  
  Email_function();
  
  if (Auth::attempt(['email' =&gt; $data['email'], 'password' =&gt; bcrypt($data['password']) ])) {
          // Authentication passed...
          return redirect('/');
      }
  </code></pre>
  
  <p>I keep getting this as my error message. </p>
  
  <pre><code>SErrorException in SessionGuard.php line 439:
  Argument 1 passed to Illuminate\Auth\SessionGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, null given, called in /Applications/XAMPP/xamppfiles/htdocs/sniddl/vendor/laravel/framework/src/Illuminate/Foundation/Auth/RegistersUsers.php on line 63 and defined
  </code></pre>
  
  <p><strong>Edit:</strong>
  changed the title to reflect the answer.</p>