Open your terminal and navigate to your local web server directory then using this following command:
//for windows user
cd xampp/htdocs
//for ubuntu user
cd var/www/html
Then install laravel 8 latest application using this command:
composer create-project --prefer-dist laravel/laravel Demo
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=db name
DB_USERNAME=db user name
DB_PASSWORD=db password
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=youremail@gmail.com
MAIL_PASSWORD=yourpass
MAIL_ENCRYPTION=tls
Install Laravel UI:
composer require laravel/ui
install auth scaffolding bootstrap package:
php artisan ui bootstrap --auth
Install Npm Packages:
npm install
cmd to run npm:
npm run dev
create database table:
php artisan migrate
<?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;
class User extends Authenticatable implements MustVerifyEmail
{
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
web.php and add the following rotues:
Auth::routes([‘verify’ => true]); Route::get(‘/home’,
[App\Http\Controllers\HomeController::class, ‘index’])->name(‘home’);
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware(['auth','verified']);
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
return view('home');
}
}
Run Development Server:
php artisan serve