You can also create redirectTo
method which laravel will give priority when redirecting your users after registration. Then remove redirectTo
property, even though method will take precedence.
public function redirectTo() {
return redirect()->back()->with('status', 'message for account activation.');
}
Inside the view (register.blade.php), you can have this.
@if (session('status'))
<div class="alert alert-success">
{{ session('status') }}
</div>
@endif
EDIT:
Please ignore the previous answer. It requires custom registration so that you can take control of what happens after registration.
Since you are using Laravel Auth, you can continue and make use of their email verification like so.
- Change
Auth::routes();
inside routes/web.php to Auth::routes(['verify'=>true]);
Add ->middleware('verified);
to the home route. This will prevent user from seeing this page until email is verified. Complete should be like so
Route::get('/home', 'HomeController@index')->name('home')->middleware('verified');
Go to App\User
and make sure that the model has the following lines in addition to all other lines you have there at the top. Focus here is on implements MustVerifyEmail
use Illuminate\Contracts\Auth\MustVerifyEmail;
class User extends Authenticatable implements MustVerifyEmail
{
//rest of the code here
}
Lastly, make sure that .env
file has the correct email settings. You can use mailtrap, it's free for testing purposes.
Hope this helps.