简体   繁体   English

Laravel认证。 如何将表“用户”更改为表“工作人员”?

[英]Laravel authentication. How do I change the table 'users' to table 'staff'?

I am a beginner just using laravel for the first time. 我是初学者,第一次使用laravel。 I adding authentication by 我通过添加身份验证

php artisan make:auth

and adding database by 并通过添加数据库

php artisan migrate

But I already have an old database. 但是我已经有一个旧数据库。 I tried to change the database from table 'users' to table 'staff' according to the code below. 我试图根据下面的代码将数据库从表'users'更改为表'staff'。

config/auth.php 配置/ auth.php

    'providers' => [
    'staff' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
    ],

Found an error in Figure 1 在图1中发现一个错误

Note I tried make a database table 'staff' like database table 'users' 注意我尝试使数据库表“ staff”像数据库表“ users”一样

Is there any file that I need to fix? 是否需要修复任何文件?

1 1

Your provider array in config/auth.php should look like this. config/auth.php provider数组应如下所示。

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\Staff::class,
    ]
]

Also, your App\\Staff model should extend Illuminate\\Foundation\\Auth\\User 另外,您的App\\Staff模型应扩展Illuminate\\Foundation\\Auth\\User

use Illuminate\Foundation\Auth\User as Authenticatable;

class Staff extends Authenticatable
{

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM