
composer create-project --prefer-dist laravel/laravel Blog |
After successfully install laravel Application, Go to your project .env file and set up database credential and move next step :
Next, migrate the table into the database using the below command :
php artisan migrate |
In this step, we will create some routes like custom login route, custom registration route, post data route, and dashboard, etc.
Route::get('login', 'AuthController@index'); | |
Route::post('post-login', 'AuthController@postLogin'); | |
Route::get('registration', 'AuthController@registration'); | |
Route::post('post-registration', 'AuthController@postRegistration'); | |
Route::get('dashboard', 'AuthController@dashboard'); | |
Route::get('logout', 'AuthController@logout'); |
We need to create a controller name AuthController. Use the below command and create Controller :
php artisan make:controller AuthController |
After successfully create controller go to app/controllers/AuthController.php and update the below code in your controller:
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
use Validator,Redirect,Response; | |
Use App\User; | |
use Illuminate\Support\Facades\Auth; | |
use Illuminate\Support\Facades\Hash; | |
use Session; | |
class AuthController extends Controller | |
{ | |
public function index() | |
{ | |
return view('login'); | |
} | |
public function registration() | |
{ | |
return view('registration'); | |
} | |
public function postLogin(Request $request) | |
{ | |
request()->validate([ | |
'email' => 'required', | |
'password' => 'required', | |
]); | |
$credentials = $request->only('email', 'password'); | |
if (Auth::attempt($credentials)) { | |
// Authentication passed... | |
return redirect()->intended('dashboard'); | |
} | |
return Redirect::to("login")->withSuccess('Oppes! You have entered invalid credentials'); | |
} | |
public function postRegistration(Request $request) | |
{ | |
request()->validate([ | |
'name' => 'required', | |
'email' => 'required|email|unique:users', | |
'password' => 'required|min:6', | |
]); | |
$data = $request->all(); | |
$check = $this->create($data); | |
return Redirect::to("dashboard")->withSuccess('Great! You have Successfully loggedin'); | |
} | |
public function dashboard() | |
{ | |
if(Auth::check()){ | |
return view('dashboard'); | |
} | |
return Redirect::to("login")->withSuccess('Opps! You do not have access'); | |
} | |
public function create(array $data) | |
{ | |
return User::create([ | |
'name' => $data['name'], | |
'email' => $data['email'], | |
'password' => Hash::make($data['password']) | |
]); | |
} | |
public function logout() { | |
Session::flush(); | |
Auth::logout(); | |
return Redirect('login'); | |
} | |
} |
Now you can create login.blade.php file and update the below code into your file:
<<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Login Form </title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<meta name="description" content=""> | |
<meta name="author" content=""> | |
<meta name="csrf-token" content="{{ csrf_token() }}"> | |
<!--Bootsrap 4 CDN--> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
<link rel="stylesheet" type="text/css" href="{{url('style.css')}}"> | |
</head> | |
<body> | |
<div class="container-fluid"> | |
<div class="row no-gutter"> | |
<div class="d-none d-md-flex col-md-4 col-lg-6 bg-image"></div> | |
<div class="col-md-8 col-lg-6"> | |
<div class="login d-flex align-items-center py-5"> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-md-9 col-lg-8 mx-auto"> | |
<h3 class="login-heading mb-4">Welcome back!</h3> | |
<form action="{{url('post-login')}}" method="POST" id="logForm"> | |
{{ csrf_field() }} | |
<div class="form-label-group"> | |
<input type="email" name="email" id="inputEmail" class="form-control" placeholder="Email address" > | |
<label for="inputEmail">Email address</label> | |
@if ($errors->has('email')) | |
<span class="error">{{ $errors->first('email') }}</span> | |
@endif | |
</div> | |
<div class="form-label-group"> | |
<input type="password" name="password" id="inputPassword" class="form-control" placeholder="Password"> | |
<label for="inputPassword">Password</label> | |
@if ($errors->has('password')) | |
<span class="error">{{ $errors->first('password') }}</span> | |
@endif | |
</div> | |
<button class="btn btn-lg btn-primary btn-block btn-login text-uppercase font-weight-bold mb-2" type="submit">Sign In</button> | |
<div class="text-center">If you have an account? | |
<a class="small" href="{{url('registration')}}">Sign Up</a></div> | |
</form> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
Now you can create registration.blade.php file and update the below code into your file
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Registration Form </title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<meta name="description" content=""> | |
<meta name="author" content=""> | |
<meta name="csrf-token" content="{{ csrf_token() }}"> | |
<!--Bootsrap 4 CDN--> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
<link rel="stylesheet" type="text/css" href="{{url('style.css')}}"> | |
</head> | |
<body> | |
<div class="container-fluid"> | |
<div class="row no-gutter"> | |
<div class="d-none d-md-flex col-md-4 col-lg-6 bg-image"></div> | |
<div class="col-md-8 col-lg-6"> | |
<div class="login d-flex align-items-center py-5"> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-md-9 col-lg-8 mx-auto"> | |
<h3 class="login-heading mb-4">Register here!</h3> | |
<form action="{{url('post-registration')}}" method="POST" id="regForm"> | |
{{ csrf_field() }} | |
<div class="form-label-group"> | |
<input type="text" id="inputName" name="name" class="form-control" placeholder="Full name" autofocus> | |
<label for="inputName">Name</label> | |
@if ($errors->has('name')) | |
<span class="error">{{ $errors->first('name') }}</span> | |
@endif | |
</div> | |
<div class="form-label-group"> | |
<input type="email" name="email" id="inputEmail" class="form-control" placeholder="Email address" > | |
<label for="inputEmail">Email address</label> | |
@if ($errors->has('email')) | |
<span class="error">{{ $errors->first('email') }}</span> | |
@endif | |
</div> | |
<div class="form-label-group"> | |
<input type="password" name="password" id="inputPassword" class="form-control" placeholder="Password"> | |
<label for="inputPassword">Password</label> | |
@if ($errors->has('password')) | |
<span class="error">{{ $errors->first('password') }}</span> | |
@endif | |
</div> | |
<button class="btn btn-lg btn-primary btn-block btn-login text-uppercase font-weight-bold mb-2" type="submit">Sign Up</button> | |
<div class="text-center">If you have an account? | |
<a class="small" href="{{url('login')}}">Sign In</a></div> | |
</form> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
Now you can create dashboard.blade.php file and update the below code into your file
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Dashboard</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<meta name="description" content=""> | |
<meta name="author" content=""> | |
<meta name="csrf-token" content="{{ csrf_token() }}"> | |
<!--Bootsrap 4 CDN--> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
<link rel="stylesheet" type="text/css" href="{{url('style.css')}}"> | |
</head> | |
<body> | |
<div class="container-fluid"> | |
<div class="row no-gutter"> | |
<div class="d-none d-md-flex col-md-4 col-lg-6 bg-image"></div> | |
<div class="col-md-8 col-lg-6"> | |
<div class="login d-flex align-items-center py-5"> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-md-9 col-lg-8 mx-auto"> | |
<h3 class="login-heading mb-4">Welcome Dashboard!</h3> | |
<div class="card"> | |
<div class="card-body"> | |
Welcome {{ ucfirst(Auth()->user()->name) }} | |
</div> | |
<div class="card-body"> | |
<a class="small" href="{{url('logout')}}">Logout</a> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
We need to start the development server. Use the PHP artisan serve command and start your server :


http://127.0.0.1:8000/ now go to this url



MotoShare.in is your go-to platform for adventure and exploration. Rent premium bikes for epic journeys or simple scooters for your daily errands—all with the MotoShare.in advantage of affordability and ease.