SQLSTATE [42S02]:未找到基本表或视图:1146 laravel上不存在表'db_wls.users'5.2
问题描述:
问题: SQLSTATE [42S02]:未找到基本表或视图:1146表'db_wls.users “不存在(SQL:SELECT COUNT(*)作为骨料从users
其中email
= [email protected])SQLSTATE [42S02]:未找到基本表或视图:1146 laravel上不存在表'db_wls.users'5.2
模型类
<?php namespace App;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
use Authenticatable, CanResetPassword;
/**
* The database table used by the model.
*
* @var string
*/
public $table = 'user';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['first_name','last_name', 'email', 'password','address','city_id'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = ['password', 'remember_token'];
public function voucher()
{
return $this->hasOne('App\Voucher');
}
public function getFullName()
{
return ucfirst(implode(" ",[$this->usr_firstname,$this->usr_lastname]));
}
}
用户表不在数据库上存在虽然。 为什么会显示此错误。
在此先感谢
答
检查您的数据库。没有名为'users'的表格,因此是错误的。
错误很明显。表“用户”不存在。 –
是的,但读取模型 –
很明显,该模型包含不同的表名称。但是没有提供代码表明模型导致错误。 –