如何使用默认认证控制器和中间件覆盖Laravel 5.1认证尝试与额外的参数?假设我有一个状态为=active
或inactive
的额外字段。我怎么写那个尝试方法呢?
正如文档中指定的那样,您可以传递一个变量数组,其键是您希望在数据库中验证值的列。
<?php
namespace App'Http'Controllers;
use Auth;
use Illuminate'Routing'Controller;
class AuthController extends Controller {
public function authenticate(Request $request)
{
$attempt = Auth::attempt([
'email' => $request->get('email'),
'password' => $request->get('password'),
'active' => $request->get('active')
]);
if ($attempt) {
return redirect()->intended('dashboard');
}
}
}