我正在尝试将登录页面重定向到管理页面。我已经指定了页面的路由以及控制器。但是,当我运行登录页面时,它会将我重定向到另一个页面而不是我希望的那个页面。请帮我解决这个问题。
routes.php文件
Route::get('/login', [ 'as' => 'login', 'uses' => 'mainController@login']);
Route::post('/logs_in', 'mainController@logs_in');
Route::get('admin', [ 'as' => 'admin', 'uses' => 'mainController@admin']);
mainController.php
public function logs_in(Request $request){
return redirect()->route('admin');
}
public function admin(){
return view('admin.dashboard');
}
login.blade.php
<form action="/logs_in" method="post">
<div class="form-group has-feedback">
<input type="email" class="form-control" name="email" placeholder="Email" required>
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" class="form-control" name="password" placeholder="Password" required>
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-8">
<div class="checkbox icheck">
<label>
<input type="checkbox"> Remember Me
</label>
</div>
</div>
<!-- /.col -->
<div class="col-xs-4">
<button type="submit" class="btn btn-primary btn-block btn-flat">Log In</button>
</div>
当我需要重定向到/ admin时,我被重定向到/ logs_in。请帮我找到我的错误。
答案 0 :(得分:0)
请在重定向内使用route('admin')
。
public function logs_in(Request $request)
{
return redirect(route('admin'));
}