Please I have a laravel website which have been working fine then all of a sudden when a user uses a referral link to register, the page will reload and redirect back to the registration page. I tried it for few times and it works then I used the new referral link to register another new account and didn't work again ever since then. And its not showing any error message but rather bounce back to same page. I have checked the RegistrationController and all the code is still fine as same before. Please I really need this help.
Thanks in Advance
Below is my RegistrationControl
`public function getRegistrationPage(){ return view('auth.register'); }
public function storeUser(Request $request){
$this->validate($request, [
'name' => 'required|max:30',
'email' => 'required|unique:users',
'phone' => 'required|min:10|unique:users',
'username' => 'required|min:5|unique:users|regex:/^\S*$/u',
'password' => 'required|string|min:6|confirmed',
'country' => 'required',
'state' => 'required',
]);
$email_code = strtoupper(Str::random(6));
$email_time = Carbon::parse()->addMinutes(5);
$phone_code = strtoupper(Str::random(6));
$phone_time = Carbon::parse()->addMinutes(5);
$upliner = Cookie::get('referral');
$uplinerUsername = Cookie::get('referral');
$email_verify = 1;
$phone_verify = 1;
$user = new User();
if($upliner == null){
$upliner = 0;
}
else{
$chkUserRef = User::where('reference', $upliner)->first();
if($chkUserRef == null){
return redirect('register');
}else{
$user_id = $chkUserRef->id;
$upliner = $user_id;
}
}
$data['name'] = $user->name = $request['name'];
$data['email'] =$user->email = $request['email'];
$user->phone = $request['phone'];
$data['username'] = $user->username = $request['username'];
$user->reference = $request['username'];
$user->country = $request['country'];
$user->state = $request['state'];
$user->under_reference = $upliner;
$user->email_verify = $email_verify;
$user->email_code = $email_code;
$user->email_time = $email_time;
$user->phone_verify = $phone_verify;
$user->phone_code = $phone_code;
$user->phone_time = $phone_time;
$data['password'] = $user->password = bcrypt($request['password']);
$saved = $user->save();
if($saved){
//send mail to the registered user
Mail::send('emails.welcome-email', ['data' => $data], function ($message) use ($data) {
$message->from('noreply@example.com', 'example.com')
->to($data['email'], $data['username'], $data['name'])
->subject('Welcome Email');
});
//send mail to Admin
$data['adminEmail'] = "example@gmail.com";
Mail::send('emails.registration-notification', ['data' => $data], function ($message) use ($data) {
$message->from('noreply@example.com', 'example.com')
->to($data['adminEmail'], $data['username'], $data['email'], $data['name'])
->subject('User Registeration Notification');
});
//send mail to referrer
if($uplinerUsername != null){
$chkReff = User::where('username',$uplinerUsername)->first();
if($chkReff == null){
return redirect('register');
}
else{
//get the person's details and send mail
$userReff = User::where('username',$uplinerUsername)->first();
$data['userEmail'] = $userReff->email;
$data['refUsername'] = $userReff->username;
Mail::send('emails.referral-notification', ['data' => $data], function ($message) use ($data) {
$message->from('noreply@example.com', 'example.com')
->to($data['userEmail'], $data['username'],
$data['refUsername'], $data['userEmail'], $data['email'], $data['name'])
->subject('Referral Notification');
});
}
}
return redirect('login');
}
`
RegistrationController
? (post the relevant part only please) - have you checked the error-logs?