// How to install Auth in laravel
// With Boothstrap
composer require laravel/ui --dev
php artisan ui bootstrap --auth
npm install && npm run dev
// With VUE
composer require laravel/ui --dev
php artisan ui vue --auth
npm install && npm run dev
Laravel's laravel/ui package provides a quick way to scaffold all of the routes and views you need for authentication using a few simple commands:
composer require laravel/ui
php artisan ui vue --auth
<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use Hash;
use Session;
use AppModelsUser;
use IlluminateSupportFacadesAuth;
class CustomAuthController extends Controller
{
public function index()
{
return view('auth.login');
}
public function customLogin(Request $request)
{
$request->validate([
'email' => 'required',
'password' => 'required',
]);
$credentials = $request->only('email', 'password');
if (Auth::attempt($credentials)) {
return redirect()->intended('dashboard')
->withSuccess('Signed in');
}
return redirect("login")->withSuccess('Login details are not valid');
}
public function registration()
{
return view('auth.registration');
}
public function customRegistration(Request $request)
{
$request->validate([
'name' => 'required',
'email' => 'required|email|unique:users',
'password' => 'required|min:6',
]);
$data = $request->all();
$check = $this->create($data);
return redirect("dashboard")->withSuccess('You have signed-in');
}
public function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password'])
]);
}
public function dashboard()
{
if(Auth::check()){
return view('dashboard');
}
return redirect("login")->withSuccess('You are not allowed to access');
}
public function signOut() {
Session::flush();
Auth::logout();
return Redirect('login');
}
}
1. if(is_global_laravel_installer_installed){
larvel new laravel_project_name
}else{
composer create-project laravel/laravel laravel_project_name
}
2. composer require laravel/ui
3. php artisan ui vue --auth
or
php artisan ui bootstrap --auth
4. npm install
5. npm run dev
Now your Laravel auth system is ready to use with latest version.
#laravel installation