将Laravel 5 Auth与自定义表字段名称一起使用? [英] Use Laravel 5 Auth with custom table field name?

查看:258
本文介绍了将Laravel 5 Auth与自定义表字段名称一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误信息是由数据库中的错误字段引起的.

The error informatin is caused by the incorrect field in the database.

QueryException in Connection.php line 620: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'email' in 'where clause'

QueryException in Connection.php line 620: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'email' in 'where clause'

auth的默认字段与数据库字段不同,我想在auth中使用数据库字段.

The default field of auth is different from the database field, I want to use the database field in auth.

例如:数据库调用user_email中的email字段,我想将数据库字段更改为auth字段.

For example: the email field in my database call user_email, I want to change the database field into the auth field.

那么,有什么办法可以做到这一点? 对不起,我的英语不好:)

So, Are there any way to do this ? Sorry for my poor English :)

THX;

推荐答案

您可以在控制器的Auth :: attemp方法中设置所需的任何列.

You can set whatever columns you like in the Auth::attemp method in your controller.

在您的情况下,以下构造应该起作用

In your case bewlow construct should work

Auth::attempt(['user_email' => $email, 'password' => $password]

这篇关于将Laravel 5 Auth与自定义表字段名称一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆