Step 1: Install Laravel 6
Initially we want to get clean Laravel 6 model utility the use of bellow command, So open your terminal OR command spark off and run bellow command:
composer create-project laravel/laravel example-app
Step 2: Install Laravel UI
You should observe few step to make auth for your laravel 6 utility.
At last go into project folder and open terminal then type and run the following command for running the project.
php artisan serve
Then Create a Table named 'users'.
3.create database and tbl users. insert user data
4.config .env file.
5. then run
composer require laravel/ui
php artisan ui vue --auth
php artisan migrate
6. now project is ready.
7. install laravel collective.
composer require laravelcollective/html
Step 3: Generate Auth Scaffold
Here, we want to generate auth scaffolding in laravel 6 the use of laravel ui command. so, let's generate it via way of means of bellow command:
personal home page artisan ui bootstrap --auth
Now you want to run npm command, in any other case you cannot see higher format of login and sign in page.
Install NPM:
npm install
Run NPM:
npm run dev
Step 4: Add Username Column
Now upload new column username on your customers table, so that you can in reality replace your migration as like bellow.
migration
Now you could run migration
personal home page artisan migrate
Step 5: Update Login View
Laravel has created default login blade file. we want to feature comman username subject on it and cast off e mail subject. so let's replace like as bellow:
Just add field "username" and "status" in User Table.
Add these field name in User Model.
Make Change in Login Page "email" to "username" and type="email" to type="text"
then edit LoginController.php
add
use Illuminate\Http\Request;
then add
public function username()
{
return "username";
}
/**
* Get the needed authorization credentials from the request.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
protected function credentials(Request $request)
{
//return $request->only($this->username(), 'password');
return ['username'=>$request->{$this->username()},'password'=>$request->password,'status'=>'1'];
}
File should be like this:
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
public function username()
{
return "username";
}
/**
* Get the needed authorization credentials from the request.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
protected function credentials(Request $request)
{
//return $request->only($this->username(), 'password');
return ['username'=>$request->{$this->username()},'password'=>$request->password,'status'=>'1'];
}
}
EmoticonEmoticon