public function postRegister(Request $request) { $validator = $this->validator($request->all()); if ($validator->fails()) { $this->ThrowValidationException($request, $validator); } $user = $this->create($request->all()); //создаем код и записываем код $code = CodeController::generateCode(8); Code::create(['user_id' => $user->id, 'code' => $code]); //Генерируем ссылку и отправляем письмо на указанный адрес $url = url('/') . '/auth/activate?id=' . $user->id . '&code=' . $code; return redirect()->to($url); }
public function change(Request $request) { $q = User::where('email_or_phone', $request->cur_email)->where('activated', 0)->update(['email_or_phone' => $request->new_email]); if ($q) { $code = CodeController::generateCode(5); Mail::send('emails.change', array('code' => $code), function ($m) use($request) { $m->to($request->new_email)->subject('Registration'); }); SMS::pretend('emails/sms', ['code' => $code], function ($sms) { $sms->to('+380678898544'); }); return "Email has been updated, check out for new code"; } }