I pull all the values (topup amount and phone number) from a form on the index page and forward it to the checkout page:
public function topupPost(Request $request) {
$validator = [
'topupAmount'=> 'required|integer|between:1,100',
'phonenumber'=> 'required|regex:/^05[602][0-9]{7}$/',
];
$inputs = $request->all();
Log::info($inputs);
$validator = Validator::make($inputs, $validator);
if($validator->fails()){
return Response::json([
'error' => true,
'message' => $validator->messages(),
'code' => 400
], 400);
}
// return "Thanks! we'll take you to payment in a Giffy!";
return view('pages.checkout', compact(inputs));
}
How can I can I access the values of inputs
which are: phonenumber
and topupAmount
in the checkout page template ?
I tried this:
<td>{{ app('inputs')->input('topupAmount') }} USD</td>
And it shows this error in the debugger :
(1/1) ErrorException Use of undefined constant inputs - assumed 'inputs' in PagesController.php (line 39) at HandleExceptions->handleError(8, 'Use of undefined constant inputs - assumed \\'inputs\\'', 'C:\\xampp\\htdocs\\onlinerecharge\\app\\Http\\Controllers\\PagesController.php', 39, array('request' => object(Request), 'validator' => object(Validator), 'inputs' => array('_token' => 'CsySUUecI0ekYNPY6oS1B2kleVHqNnrUKBpHbYwa', 'phonenumber' => '0501234567', 'topupAmount' => '1'))) in PagesController.php (line 39)
您可以按以下方式访问pages / checkout.blade.php中的值:
{{ $inputs['phonenumber'] }}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.