From ee9a01651dcd5b9755b7e51b4cbdf4f759c4c01b Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 14 Sep 2018 17:00:28 -0300 Subject: [PATCH] Adding a Welcome Mail --- .../Controllers/Auth/RegisterController.php | 7 +++- app/Mail/Welcome.php | 35 +++++++++++++++++++ resources/views/emails/welcome.blade.php | 14 ++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 app/Mail/Welcome.php create mode 100644 resources/views/emails/welcome.blade.php diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index e749c07..32d4433 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Auth; use App\User; +use App\Mail\Welcome; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; @@ -63,10 +64,14 @@ class RegisterController extends Controller */ protected function create(array $data) { - return User::create([ + $user = User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => Hash::make($data['password']), ]); + + \Mail::to($user)->send(new Welcome($user)); + + return $user; } } diff --git a/app/Mail/Welcome.php b/app/Mail/Welcome.php new file mode 100644 index 0000000..806d6df --- /dev/null +++ b/app/Mail/Welcome.php @@ -0,0 +1,35 @@ +user = $user; + } + + /** + * Build the message. + * + * @return $this + */ + public function build() + { + return $this->markdown('emails.welcome'); + } +} diff --git a/resources/views/emails/welcome.blade.php b/resources/views/emails/welcome.blade.php new file mode 100644 index 0000000..af7be8b --- /dev/null +++ b/resources/views/emails/welcome.blade.php @@ -0,0 +1,14 @@ +@component('mail::message') +# Welcome, {{$user->name}}, + +Thank's for registering at **Share It!** + +Your account was created and it is active. And you? Are you ready to Share It with your friends? :) + +@component('mail::button', ['url' => 'https://shareit.brunofontes.net']) +Share it! +@endcomponent + +Thanks,
+{{ config('app.name') }} +@endcomponent