【发布时间】:2016-08-31 17:50:05
【问题描述】:
问题:
SQLSTATE [42S02]:未找到基表或视图:1146 表 'db_wls.users' 不存在(SQL:从users 中选择计数(*)作为聚合,其中email = onlynadim0000@gmail.com)
模型类
<?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不存在。 -
是的,但请阅读模型
-
很明显模型包含不同的表名。但是没有提供表明模型导致错误的代码。
-
我提到了模型上的表名。这应该可以
-
您提到 $table="user" 将其更改为用户。查看您的模型类代码
标签: php authentication eloquent laravel-5.2