繁体   English   中英

SQLSTATE[42S02]:未找到基表或视图:1146 Laravel 5.2 上不存在表“db_wls.users”

[英]SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db_wls.users' doesn't exist on laravel 5.2

问题:SQLSTATE[42S02]:未找到基表或视图:1146 表 'db_wls.users' 不存在(SQL:选择计数(*)作为来自email = onlynadim0000@gmail.com 的users聚合)

模型类

<?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]));
    }

}

虽然用户表确实存在于数据库中。 为什么显示此错误。

提前致谢

您可以在模型中覆盖它。

公共 $table = '用户'

检查您的数据库。 没有名为“users”的表,因此出现错误。

暂无
暂无

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

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