I need to implement login features in Laravel 5.2. I have successfully done this using the official Laraval documentation, except that I do not know how to authenticate the user using the column names of the database table, namely st_username and st_password .
I searched the Internet for tips, but to no avail. I do not know which class I need to use (for example, use Illuminate .......) for Auth. If anyone knows the answer, please let me know.
Here is my code:
Login
@extends('layouts.app') @section('content') <div class="contact-bg2"> <div class="container"> <div class="booking"> <h3>Login</h3> <div class="col-md-4 booking-form" style="margin: 0 33%;"> <form method="post" action="{{ url('/login') }}"> {!! csrf_field() !!} <h5>USERNAME</h5> <input type="text" name="username" value="abcuser"> <h5>PASSWORD</h5> <input type="password" name="password" value="abcpass"> <input type="submit" value="Login"> <input type="reset" value="Reset"> </form> </div> </div> </div> </div> <div></div> @endsection
Authcontroller
namespace App\Http\Controllers\Auth; use App\User; use Validator; use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\ThrottlesLogins; use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers; class AuthController extends Controller { use AuthenticatesAndRegistersUsers, ThrottlesLogins; protected $redirectTo = '/home'; public function __construct() { $this->middleware('guest', ['except' => 'logout']); $this->username = 'st_username'; $this->password = 'st_password'; } protected function validator(array $data) { return Validator::make($data, [ 'name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6', ]); }
Route File
Route::get('/', function () { return view('index'); }); Route::group(['middleware' => 'web'], function () { Route::auth(); Route::get('/home', ' HomeController@index '); });
config / auth.php
return [ 'defaults' => [ 'guard' => 'web', 'passwords' => 'users', ], 'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ], 'api' => [ 'driver' => 'token', 'provider' => 'users', ], ], 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\User::class, ],