如何使用不同的 table 默认设置身份验证 laravel
How make authentiation laravel with deferent table default
我的数据库 radius
和 table radcheck
没有迁移。我想要 table radcheck
作为 table 身份验证,而不是 users.i 尝试将 config/auth
从 'user' 更改为 radcheck
。但是一个错误
Table 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
中将 config/auth 从用户更改为 radcheck:
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Model\Management\Radcheck::class,
],
错误如下所示:
Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\Model\Management\Radcheck given, called in C:\xampp\htdocs\e-access\system\vendor\laravel\framework\src\Illuminate\Auth\SessionGuard.php on line 385 and defined
模型应该扩展 Authenticable
:
use Illuminate\Foundation\Auth\User as Authenticable;
class Radcheck extends Authenticable
EloquentUserProvider
仅接受 Illuminate\Foundation\Auth\User
的实例,因此您需要将 RadCheck 扩展 Illuminate\Foundation\Auth\User
只需按照以下代码
更改您的 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');
}
}
我的数据库 radius
和 table radcheck
没有迁移。我想要 table radcheck
作为 table 身份验证,而不是 users.i 尝试将 config/auth
从 'user' 更改为 radcheck
。但是一个错误
Table 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
中将 config/auth 从用户更改为 radcheck:
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Model\Management\Radcheck::class,
],
错误如下所示:
Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\Model\Management\Radcheck given, called in C:\xampp\htdocs\e-access\system\vendor\laravel\framework\src\Illuminate\Auth\SessionGuard.php on line 385 and defined
模型应该扩展 Authenticable
:
use Illuminate\Foundation\Auth\User as Authenticable;
class Radcheck extends Authenticable
EloquentUserProvider
仅接受 Illuminate\Foundation\Auth\User
的实例,因此您需要将 RadCheck 扩展 Illuminate\Foundation\Auth\User
只需按照以下代码
更改您的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');
}
}