使用不同的表名时,Laravel Auth问题

时间:2014-12-29 06:52:35

标签: php mysql authentication laravel laravel-4

这个问题是this

的延续

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

现在我将其更改为admin

所以我审阅了here

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

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

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

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

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

这是我的控制器:

  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 个答案:

没有答案