在Laravel中使用不同的表进行身份验证

时间:2014-12-29 05:10:54

标签: php laravel laravel-4

我尝试使用Laravel Auth用途的默认user表,

现在我将其更改为admin

所以我审阅了here

因此我尝试将表名更改为auth.php中的admin

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

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

在AdminModel中我有protected $table = 'admin';

我收到了错误

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, ...)

有什么应该改变而不是在这里吗?

这是我的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();    
}

更新:

我替换了适当的更改

即,

use UserTrait, RemindableTrait;

解决,

它没有成功结束

我检查了

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

它总是像这样打印查询

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

可能是什么问题?

0 个答案:

没有答案