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

时间:2016-08-31 17:50:05

标签: php authentication eloquent laravel-5.2

Problem : SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db_wls.users' doesn't exist (SQL: select count(*) as aggregate from users where email = onlynadim0000@gmail.com)

Model Class

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

}

User table does exist on the database though. Why this error is showing.

Thanks In advance

2 个答案:

答案 0 :(得分:0)

您可以在模型中覆盖它。

public $ table ='用户'

答案 1 :(得分:-1)

检查您的数据库。没有名为&#39; users&#39;因此错误。