douzhi9939 2014-12-29 05:10
浏览 36

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

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 ?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 2024-五一综合模拟赛
    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭