php - 我想在 laravel 中使用用户名或电子邮件更新登录
问题描述
我已将 laravel 默认make:Auth更新为使用用户名和电子邮件登录。我只是有覆盖用户名功能
loginController.php到:
public function username()
{
$loginType = request()->input('username');
$this->username = filter_var($loginType , FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
request()->merge([$this->username => $loginType]);
$this->property_exists($this, 'username') ? $this->username : 'email';
}
但出现错误:
Method [property_exists] does not exist on [App\Http\Controllers\Auth\LoginController].
解决方案
property_exists
是一个 php 函数,而不是某个类的方法。所以,要改善这个错误,只需重写你的代码:
public function username()
{
$loginType = request()->input('username');
$this->username = filter_var($loginType , FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
request()->merge([$this->username => $loginType]);
property_exists($this, 'username') ? $this->username : 'email';
}
推荐阅读
- typescript - 混合项目中 .js 文件的 Typescript 声明
- azure - 如何减少 Azure Web 应用临时文件的使用
- hyperledger-fabric - Hyperledger Fabric - 将私人数据从一个人的集合复制到另一个组织的集合
- android - 使用 Intents 时回栈不断添加
- java - 在 Eclipse 中从 git 导入后,出现错误“源文件夹不是 java 项目”
- vue.js - vuejs v-validate 自定义验证规则:最大值必须大于用户输入的最小值
- java - 在java中更改字符串中的字符
- google-apps-script - GoogleSheets - 如何对由 (Filter(Importrange) 提取的数据进行 AZ 排序
- c++ - 为什么我的对象向量中的元素在调用对象成员函数之一时没有更新?
- .net - 如何使用 ASP .net core webapi 开发简单的 web api?