1 year ago

Email user after registration

Posted 1 year ago by Danieloplata

Hi guys, so I just watched the video from 5.4 from scratch where Jeffrey emails a user after creating their account and as I'm watching a series that is a little out of date.. The code has changed a bit since the video.

The "RegistrationController" is now "RegisterController"

protected function create(array $data)
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        \Mail::to($user)->send(new Welcome($user));

No email is being sent using the above.

I've tested that the emails are working. The command below works perfectly in tinker:

Mail::to($user = App\User::first())->send(new App\Mail\Welcome($user));

My concern here is that I'm not sure how to access the newly created User object with this new code layout.

No error shown, so I'm not sure how to debug this.

Please sign in or create an account to participate in this conversation.