令人困惑的情况

女牛仔

我处于非常混乱的境地

我有这样的控制器逻辑

public function book(Request $request)
{
  //setting API class
  $business = new API();

  //getting name and number for sending verification code
  $name = $request->name;
  $number = $request->number;

  //sending verification code to number 
  $business->sendVerificationCode($number);

 //sending user back to show a form to enter verification code
 return back()->with('modalForEnteringConfirmation', ' ');

}

我正在将验证码发送到所请求的号码。我将返回一个模态,该模态具有一个输入验证码的表格。

我的问题是获取那个VerificationCode值,以便我可以在book控制器中进一步进行操作

//receiving confirmation code
$code = $request->confirmation;

//booking if confirmation code matches
$book = $business->bookingNumber($name, $code);

现在,我无法在back()函数中发送变量,如何获取确认代码?我似乎无法理解。

Oluwatobi塞缪尔·奥米萨金

您可以使用on该功能将刷新的数据发送到下一个请求因此,在您看来,您必须使用帮助程序方法检查该数据withbackrequest()->session()->get()session()

假设您像这样通过控制器发送验证码:

...
return back()->with('verification_code', $verification_code);

然后在您看来,您将已经在模式中 verification_code

<-- Say this is your modal content section -->
@if (request()->session()->has('verification_code'))
      {{ request()->session()->get('verification_code') }}
    // you should have the code here
@endif

当然,我不知道您是如何构建模态表单的,但是在编写html代码时,如果您在表单中包含上述数据,那么只要找到它就应该可以使用它。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章