Laravel - User Login and Register Page with Verify With Email feature
Mohamad's interest is in Programming (Mobile, Web, Database and Machine Learning). He is studying at the Center For Artificial Intelligence Technology (CAIT), Universiti Kebangsaan Malaysia (UKM).
This tutorial uses Laragon development environment.
[1] Start with a newly created project
Refer https://hashnotes.hashnode.dev/create-laravel-api-site-using-laragon
[2] Install Package
Open the Cmder console window.
Change directory to your project directory, e.g. rearnet.

Get Breeze package.
composer require laravel/breeze --dev
Install Breeze package.
php artisan breeze:install
Select ...
breeze
no dark support
PHPUnitTest

Wait for installation to complete.

[3] Test the generated pages
[3.1] http://localhost/rearnet/public/

[3.2] http://localhost/rearnet/public/register

[3.3] http://localhost/rearnet/public/login

[4] Migrate database
(Remember: to change the sqlite database path in the .env file so that it follows the Windows path style i.e. )
DB_DATABASE=database/rear.sqlite
Otherwise, you may get the following error:

Run migration command:
php artisan migrate

[5] Implement Must Verify Email feature
Activate the use statement for MustVerifyEmail and implements MustVerifyEmail features.
use Illuminate\Contracts\Auth\MustVerifyEmail;
class User extends Authenticatable implements MustVerifyEmail
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable implements MustVerifyEmail
{
use HasApiTokens, HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
[6] Test
Warning: before testing, make sure that ...
You have changed the sqlite database path to Linux-style path:
- e.g. ../database/rear.sqlite
You have entered correct config information for:
MAIL_MAILER,
MAIL_HOST,
MAIL_PORT,
MAIL_USERNAME,
MAIL_PASSWORD,
MAIL_ENCRYPTION,
MAIL_FROM_ADDRESS and
MAIL_FROM_NAME.

Outcome:

Check mailbox:

Click the link:

Check in the user table:
