在我的情况下,我必须检查用户是否已注册,如果是,他应该重定向到主页,否则他可以注册,如果状态是1则他不能注册。
public function register()
{
$userDetails = StartupAward::where('email', '=', Input::get('email'))->first();
$status = StartupAward::where('status','=',1)->first();
if($userDetails->status == 1 )
{
return "you are already registered";
}
elseif($userDetails != null)
{
$getEmail = $request->get('email');
$userDetails->name= $request->name;
$userDetails->organization = $request->organization;
$userDetails->save();
$email = StartupAward::where('email','=',$getEmail)->first();
$request->session()->put('id', $email);
return redirect('iot-start-up-awards');
}
elseif($userDetails == null || $userDetails->status != 1)
{
$getEmail = $request->get('email');
$input['name'] = $request->name;
$input['email'] = $request->email;
$input['organization'] = $request->organization;
StartupAward::create($input);
$email = StartupAward::where('email','=',$getEmail)->first();
$request->session()->put('id', $email);
Mail::send('email.toughtLeaderEmail',['useremail' =>
Input::get('email')] ,function($message) {
$message->to('manjunath@designesthetics.com', Input::get('email'))
->subject('Startup Award Nomination Form');
});
return redirect('iot-start-up-awards');
}