douyinlai2169 2017-09-29 17:39
浏览 233
已采纳

SQLSTATE [42S02]:找不到基表或视图

I am using Laravel Auth to register and login my users into the respective dashboard. I am using admin as my user. I created the migration for admin, but when i try to register my admin error comes Table or view not found and the table which is not found is the built in table users which i deleted because i was not using that one. I have to use the admin table please help me how can i remove this error.

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

  • 写回答

2条回答 默认 最新

  • dty9731 2017-09-29 21:24
    关注

    There may be some possibilities that i have mention below:

    1) In the config/auth.php change the users model to your company class.

       'providers' => [
            'users' => [
                'driver' => 'eloquent',
                'model' => App\Admin::class,
        ],
    

    2) In the Admin class, define fillable and hidden fields:

    class Admin extends Authenticatable {
    
    protected $fillable = [
        'name', 'email', 'password',
    ];
    
    protected $hidden = [
        'password', 'remember_token',
    ];
    }
    

    3) Do not forget to change validation in registerContoller.

    'email' => 'required|string|email|max:255|unique:admins',
    

    4)Clear the config cache or rebuild it:

     php artisan config:clear  
     php artisan config:cache
    

    References:

    https://laracasts.com/discuss/channels/general-discussion/change-users-table-name

    https://laracasts.com/discuss/channels/general-discussion/changing-users-table-name-52

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable