Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel give array to route, not all values are required

Tags:

php

laravel

I'm getting this error

Missing required parameters for [Route: payment.checkPayment] [URI: {unique_link}/{paymentrequest}/{info}].

Here I encode the array. Note is optional, is also nullable in database.

$info = json_encode(["name" => $request->name, "note" => $request->note]);

This is where I'm sending it to the route

route('payment.checkPayment', [$uniquelink, $paymentrequest, $info])

Route

Route::get('/{unique_link}/{paymentrequest}/{info}', ['as' => 'payment.checkPayment', 'uses' => 'PaymentController@checkPayment']);

How would I fix this? It seems to me I'm sending all of the parameters.

like image 495
validationn Avatar asked May 31 '26 22:05

validationn


1 Answers

You need to use key-value arrays instead of array-lists as you do:

use:

route('payment.checkPayment', ['unique_link'=>$uniquelink, 'paymentrequest'=>$paymentrequest, 'info'=>$info]);

Reference Laravel Named routes

NOTE it seems you use json-encoded value for the info field, but NOT SURE if this will generate a valid URI. Better check it.

like image 51
Nikos M. Avatar answered Jun 03 '26 17:06

Nikos M.