duanfei9278
2015-04-28 21:54
浏览 162
已采纳

Laravel 5 Auth - 用户自定义表

I'm learning Laravel auth now and I have small problem. I read some pages from Google about this mechanism and I'm using

Auth::attempt(['email'=>$request['email'],'password'=>$request['password']]);

Laravel gives me this error:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'base.users' doesn't exist (SQL: select * from `users` where `email` = admin@domain.com limit 1)

In fact I don't have users table in my database, I'm using name accounts. How can I change default table in auth?

And additional question is: when I put data to Auth::attempt() data will changed to SQL query and all data will be get from base? How can I add more data than I get in base? For simple I have table ban which this field have number of days when ban goes end. And I want to add field isbanned which get TRUE/FALSE data. If ban>0 will be TRUE, otherwise FALSE.

图片转代码服务由CSDN问答提供 功能建议

我现在正在学习Laravel auth,我的问题很小。 我从谷歌读了一些关于这种机制的页面,我正在使用

  Auth :: attempt(['email'=> $ request ['email'],'password  '=> $ request ['password']]); 
   
 
 

Laravel给了我这个错误:

  SQLSTATE [42S02]:未找到基表或视图:1146表'base.users'不存在(SQL:select * from`users`,其中`email` = admin@domain.com limit 1)
   
 
 

实际上我的数据库中没有 users 表,我正在使用名称 accounts 。 如何在auth中更改默认表?

还有一个问题是:当我将数据放入Auth :: attempt()时,数据将更改为SQL查询,所有数据都将从基数获取 ? 如何添加比基础数据更多的数据? 为简单起见,我有表 ban ,这个字段有禁止结束的天数。 我想添加字段 isbanned ,它获取TRUE / FALSE数据。 如果 ban > 0将为TRUE,否则为FALSE。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • dti70601 2015-04-28 22:00
    最佳回答

    In config/auth.php change 'table' => 'users' to 'table' => 'accounts'

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题