dimanche 28 février 2016

How to get login with different database table column name inn Laravel 5.2?

I have to implement login functionality in Laravel 5.2. As per laravel official docs, I success ed. But now, problem is that I have to authenticate user on different database table column name. i.e, st_username and st_password. So I don't know how to implement that. I have searched on Internet for this. But there is exapmles with fully manual login functionality. And in some, they uses Auth. But I don't know that which class I need to use (like, use Illuminate.......) for Auth. If any one knows the answer, answer will be appreciated. Here is my code.

Login View

@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="akkivaghasiya5">
                    <h5>PASSWORD</h5>
                    <input type="password" name="password" value="akkivaghasiya5">

                    <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');
});



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1SboZwE
via IFTTT

Aucun commentaire:

Enregistrer un commentaire