Adding a Welcome Mail

This commit is contained in:
Bruno F. Fontes 2018-09-14 17:00:28 -03:00
parent ea3ffaad39
commit ee9a01651d
3 changed files with 55 additions and 1 deletions

View File

@ -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;
}
}

35
app/Mail/Welcome.php Normal file
View File

@ -0,0 +1,35 @@
<?php
namespace App\Mail;
use \App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class Welcome extends Mailable
{
public $user; //Keep this public to be accessed directly from the view.
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(User $user)
{
$this->user = $user;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('emails.welcome');
}
}

View File

@ -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,<br>
{{ config('app.name') }}
@endcomponent