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

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 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化