我試着去創造登錄表單及其控制器,但是當我嘗試登錄它不工作任何一個可以幫助我,我在laravel很新。Laravel 5.4認證
這裏是我的形式
<form action="/login" method="post">
{{ csrf_field() }}
<div class="form-group has-feedback">
<input type="email" name="email" class="form-control" placeholder="Email">
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" name="password" class="form-control" placeholder="Password">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-7">
<div class="checkbox">
<label>
<input type="checkbox"> Remember Me
</label>
</div>
</div>
<!-- /.col -->
<div class="col-xs-5">
<button type="submit" class="btn btn-primary btn-raised btn-block ">Sign In</button>
</div>
<!-- /.col -->
</div>
</form>
,這裏是我的路線
Route::get('/login', '[email protected]');
Route::post('/login', '[email protected]');
和我的LoginController是
class loginController extends Controller
{
public function __construct(){
$this->middleware('guest', ['except' => 'destroy']);
}
public function create(){
return view('pages.admin.login');
}
public function store(){
if(! auth()->attempt(request(['email', 'password']))){
return back()->withErrors([
'message' => 'Please check your credentials'
]);
}
return redirect('/home');
}
}
我的用戶模式是
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'fname','oname','lname', 'email', 'phone','password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
請在那裏我我對這些,你發送請求的返回值做錯了,當我輸入的電子郵件和密碼,我的憑據只是刷新並返回到登錄頁面
請添加錯誤消息 –
它不會引發錯誤 – ProtanzaPlus