我已经创建了一个自定义登录(不使用默认的laravel auth),这是我需要调整的一些业务设计强制原因。有没有办法让所有Auth程序(检查会话,登录,注销等)都会查看另一个表?我的谷歌研究指出我使用config / auth.php来更改那里的表值,但是当我打开它时,没有表格'配置中的值,所以我手动添加它
'table' => 'user_admin',
..遗憾的是,一切都没有改变。会话检查仍会检查用户表。
感谢您的任何意见。
答案 0 :(得分:0)
转到
配置/ auth.php
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
您可能还需要修改RegisterController中的验证器方法
您可以在迁移file中更改表名,然后在User.php模型中更改表名变量。
示例:强>
class MyTable extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'my_table';
}
https://laravel.com/docs/5.4/eloquent#eloquent-model-conventions