Home  >  Article  >  Backend Development  >  Laravel 5.1 使用用户名登陆

Laravel 5.1 使用用户名登陆

WBOY
WBOYOriginal
2016-06-20 12:46:44874browse

如果你稍微研究下laravel登陆的话,能找到这段代码

public function loginUsername(){    return property_exists($this, 'username') ? $this->username : 'email';}

这里做了判断 是否存在属性username 没有及用email.

所以想用用户名登陆的话,就直接改下AuthController.php 增加个username的属性就OK了。

protected $username = 'name';

视图里

<div class="form-group">    <label class="col-md-4 control-label">Username</label>    <div class="col-md-6">        <input type="text" class="form-control" name="name">    </div></div>

原文:http://note.mango.im/article/26

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP控制站点并发Next article:数据传输