首页 > 解决方案 > Laravel 从链接路由中获取 OTP 和电话

问题描述

在登录页面中,我从用户那里获取电话号码,并向 POST 方法中的号码发送 otp 代码。这是我的登录表单按钮:

<button type="submit" formaction="{{url('/client-mobile-login')}}" class="mobile-login__button">CONTINUE
</button>

这是我的路线:

Route::post('/client-mobile-login', 'ClientLoginController@client_mobile_login');

这是我的控制器功能:

  public function client_mobile_login(Request $request)
{
 ...otp code here...(otp sending successfully)
 .....
  if($output){
                
  return redirect("otp/".base64_encode($otp).'/'.base64_encode($client_phone1));
           
   }

发送 otp 后,我想在链接上查看带有编码 otp 和电话号码的 otp 页面。这是我的 otp 路线。

Route::get('/otp/{otp}/{phone_number}', 'ClientLoginController@get_otp');

这是getotp函数

  public function get_otp(Request $otp = NULL,$phone_number = NULL){
    

    if ($otp != NULL AND $phone_number != NULL) {
        $data['otp'] = $otp;
        $data['phone_number'] = $phone_number;
        return view('otp',compact('data'));    

    }
}

我在地址栏中获取链接,但未呈现 otp 页面

标签: phplaravellaravel-blade

解决方案


推荐阅读