当我成功登录时,没有问题我只是登录 . 但是当我输入错误的凭据时它会给我这个错误:
类型错误:传递给Illuminate \ Auth \ SessionGuard :: login()的参数1必须实现接口Illuminate \ Contracts \ Auth \ Authenticatable,null给定,在C:\ xampp \ htdocs \ project \ vendor \ laravel \ framework \ src中调用第294行\照亮\ Auth \ AuthManager.php
这是我的登录控制器:
<?php
namespace App\Http\Controllers\Auth;
use \Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use App\Account;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
}
public function login()
{
$user = Account::where('email', request()->email)
->where('password',bcrypt(request()->password))
->first();
Auth::login($user);
return redirect('/');
}
}
我的帐户(用户)模型:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Auth\Authenticatable as AuthenticableTrait;
class Account extends Authenticatable
{
use Notifiable;
use AuthenticableTrait;
public $timestamps = false;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'username', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
我究竟做错了什么?