You can modify Laravel 5 default registrar located in app/services
<?php namespace App\Services;
use App\User;
use Validator;
use Illuminate\Contracts\Auth\Registrar as RegistrarContract;
use Mail;
class Registrar implements RegistrarContract {
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
public function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6'
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
public function create(array $data)
{
$user = User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => \Hash::make($data['password']),
//generates a random string that is 20 characters long
'verification_code' => str_random(20)
]);
//do your role stuffs here
//send verification mail to user
//---------------------------------------------------------
$data['verification_code'] = $user->verification_code;
Mail::send('emails.welcome', $data, function($message) use ($data)
{
$message->from('[email protected]', "Site name");
$message->subject("Welcome to site name");
$message->to($data['email']);
});
return $user;
}
}
Inside resources/emails/welcome.blade.php
Hey {{$name}}, Welcome to our website. <br>
Please click <a href="{!! url('/verify', ['code'=>$verification_code]) !!}"> Here</a> to confirm email
NB: You need to create route/controller for verify