如何使用默认表默认的认证laravel

时间:2017-01-18 10:28:54

标签: laravel authentication laravel-5.3 guard

我有数据库hotfixes,表radius没有迁移。我希望表radcheck作为表格身份验证,而不是用户。我尝试从用户'更改radcheckconfig/auth。但是错误

radcheck

radcheck

id, username, attribute, op, value=> as password, barcode 中的代码:

radcheck.php

然后,我在namespace App\Model\Management; use Illuminate\Database\Eloquent\Model; class Radcheck extends Model { protected $table = 'radcheck'; protected $primarykey = 'id'; protected $fillable = ['id','username','attribute','op','value','barcode']; public $timestamps = false; public function radusergroups(){ return $this->hasMany('App\Model\Management\Radusergroup'); } } 中将config / auth从用户更改为radcheck:

Config/auth

错误如下所示:

  

传递给Illuminate \ Auth \ EloquentUserProvider :: validateCredentials()的参数1必须是Illuminate \ Contracts \ Auth \ Authenticatable的实例,App \ Model \ Management \ Radcheck的实例,在C:\ xampp \ htdocs \中调用第385行的e-access \ system \ vendor \ laravel \ framework \ src \ Illuminate \ Auth \ SessionGuard.php并定义

2 个答案:

答案 0 :(得分:1)

The model should extend Authenticable:

use Illuminate\Foundation\Auth\User as Authenticable;

class Radcheck extends Authenticable

答案 1 :(得分:1)

EloquentUserProvider仅接受Illuminate\Foundation\Auth\User的实例,因此您需要按Illuminate\Foundation\Auth\User

扩展您的RadCheck

只需按照以下代码更改RadCheck

即可

radcheck.php

namespace App\Model\Management;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Radcheck extends Authenticatable
{
    use Notifiable;

    protected $table = 'radcheck';
    protected $primarykey = 'id';
    protected $fillable = ['id','username','attribute','op','value','barcode'];
    public $timestamps = false;
public function radusergroups(){
      return $this->hasMany('App\Model\Management\Radusergroup');
    }
}