SQLSTATE [42S02]:找不到基表或视图
I am using Laravel Auth to register and login my users into the respective dashboard. I am using admin as my user. I created the migration for admin, but when i try to register my admin error comes Table or view not found and the table which is not found is the built in table users which i deleted because i was not using that one. I have to use the admin table please help me how can i remove this error.
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'fyp.users' doesn't exist (SQL: select count() as aggregate from users where email =**********)
我正在使用 Laravel Auth strong>注册并将我的用户登录到相应的信息中心。 SQLSTATE [42S02]:未找到基表或视图:1146表'fyp.users'不存在(SQL:select count()作为用户的聚合 其中email = **********) p>
blockquote>
div>我使用admin作为我的用户 code>。 我为管理员创建了迁移,但是当我尝试注册管理员错误时,表或视图未找到 code>,找不到的表是我删除的内置表用户,因为我没有使用 那个。 我必须使用管理表请帮助我如何删除此错误。 p>
There may be some possibilities that i have mention below:
1) In the config/auth.php change the users model to your company class.
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
],
2) In the Admin class, define fillable and hidden fields:
class Admin extends Authenticatable {
protected $fillable = [
'name', 'email', 'password',
];
protected $hidden = [
'password', 'remember_token',
];
}
3) Do not forget to change validation in registerContoller.
'email' => 'required|string|email|max:255|unique:admins',
4)Clear the config cache or rebuild it:
php artisan config:clear
php artisan config:cache
References:
https://laracasts.com/discuss/channels/general-discussion/change-users-table-name
https://laracasts.com/discuss/channels/general-discussion/changing-users-table-name-52
Edit app/config/auth.php to change the table.
'table' => 'admin',
Source: http://laravel-recipes.com/recipes/12/changing-your-authentication-table
EDIT: That was for Laravel 4. For Laravel 5, it depends on the driver you're using. If you're using Eloquent, you can change the default model in your config/auth.php file here:
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class, // Here you can change the users model
],
],
or you can specify the right table in the App\User model.
If you're using the database driver, you can change the name of the table in the same way:
'providers' => [
'users' => [
'driver' => 'database',
'table' => 'users', // Here you can change the database table
],
],
Hope that helps.