Using different Table for Authentication in Laravel

萝らか妹 提交于 2019-12-25 04:07:37

问题


I tried with the default user table for Laravel Auth purpose,

Now i am changing it to the admin Table

So i refereed here

Accordingly i tried to change the Table name as admin in the auth.php

'model' => 'User',
'table' => 'users',

to

'model' => 'AdminModel',
'table' => 'admin',

And in the AdminModel i have protected $table = 'admin';

And i got the error

Class AdminModel contains 6 abstract methods and must therefore be declared abstract or implement the remaining methods (Illuminate\Auth\UserInterface::getAuthIdentifier, Illuminate\Auth\UserInterface::getAuthPassword, Illuminate\Auth\UserInterface::getRememberToken, ...)

Is there anything is should change rather than here ?

Here is my AdminModel :

<?php
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;

class AdminModel extends Eloquent implements UserInterface, RemindableInterface 
{
    protected $table = 'admin';
    protected $fillable = array('UserName', 'Password');    
    public $timestamps = true;
    public static $rules = array();    
}

Update :

I replaced with appropriate changes

i.e.,

use UserTrait, RemindableTrait;

Solved,

It didn't ended in success

I checked

  if (Auth::attempt(array('UserName' => $UserName, 'password' => $password)))
    {
        return Redirect::intended('dashboard');
    }
    else
    {
    $queries = DB::getQueryLog();
    print_r(end($queries));
    }

And it is always printing the query like this

Array ( [query] => select * from `admin` where `UserName` = ? limit 1 [bindings] => Array ( [0] => a ) [time] => 1 )

What might be the issue ?

来源:https://stackoverflow.com/questions/27683709/using-different-table-for-authentication-in-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!