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

authenticationeloquentlaravel-5.2PHP

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

Best Answer

You can override this in your model.

public $table = 'users'

Related Topic