我在我的布局创建用户(作为注册选项)的模式,我可以正确地创建用户,但我需要自动登录并将他重定向到另一个页面,我该怎么做?如何使用Laravel框架创建注册模式?
这里是我的代码:
我的头布局模式
<div id="LoginModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content" style="background-image: url(/assets/img/Login/Email_Gate.png);width: 420px;height: 550px;">
<div class="modal-body" style="padding:0;">
<div class="tabbable">
<ul class="nav nav-tabs" id="LoginNavUl" style="margin:50px;">
<li style="width: 150px;margin: 0; height: 47px;"><a href="#tab1" data-toggle="tab" aria-expanded="false" style="text-align: center;">Sign Up</a></li>
<li class="active" style="width: 150px;margin: 0;"><a href="#tab2" data-toggle="tab" aria-expanded="true" style="text-align: center;">Login</a></li>
</ul>
<div class="tab-content active">
<div class="tab-pane" id="tab1">
<div class="green-banner" style="background-color: #04c08d; height: 60px;">
<p>Nice to meet you.</p>
</div>
<div class="content-login" style="padding-left:70px; padding-right:70px; padding-top:50px;">
<form id="formRegister" class="form-horizontal" role="form" method="POST" action="{{ route('signup') }}">
<input type="hidden" name="_token" value="{{ Session::token() }}">
<input type="email" class="form-control" name="email" style="width: 100%;" placeholder="Email"><br/>
<input type="password" class="form-control" name="password" style="width: 100%;" placeholder="Password"><br/>
<input type="date" style="width: 100%; margin-bottom: 70px;" name ="eventdate" placeholder="Event Date"/><br/>
<div class="btn-submit-login">
<div>
<button id="edit-submit" name="op" type="submit" style="border: none;background-color: transparent;">SIGN UP</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
我的控制器:
public function createUser(Request $request)
{
$email = $request['email'];
$password = bcrypt($request['password']);
$user = new UserModel();
$user->email = $email;
$user->password = $password;
$user->role_id = 3;
$user->save();
/*
I need to log the user here
*/
if user is logged in {
Redirect::to('/collection');
} else {
Redirect::to('/');
}
}
https://laravel.com/docs/5.3/authentication –