将Laravel 5 Auth与自定义表字段名称一起使用?

编程入门 行业动态 更新时间:2024-10-25 04:25:02
本文介绍了将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与自定义表字段名称一起使用?

本文发布于:2023-10-24 19:32:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524808.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表字   自定义   名称   Laravel   Auth

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!