mardi 29 août 2017

How to forward form values from one view to another using $request->all(); ? Laravel 5

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|http://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> 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)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire