We are getting a weird error and I've looked at our Git history and no one has touched this controller and routes belonging to them in several months.
We have a form that takes the GET
Request
data from a page and passes them from Step 1 to Step 2. So the variables are inserted into the URL such as /refer/step_2?name='john'&phone="9999999999"
etc.
Error:
Missing required parameters for [Route: step_2] [URI: refer/step/2].
Step 2 (Post Request):
/**
* Validates data from step and moves on to step 2.
*
* @param Request $request
*/
public function step1_request(Request $request) {
// Remove any additional characters from the lead phone number.
$request['phone'] = preg_replace('/\D+/', '', $request->phone);
$request->merge(['phone' => $request['phone']]);
$validate = [
'name' => 'required',
'phone' => 'required|digits:10'
];
$validationErrorMessages = [
'phone.digits' => 'The phone number must be 10 digits. No spacing, dashes, or special characters.'
];
$validateData = $request->validate($validate, $validationErrorMessages);
//dd returns fine here.. includes the request data.
return redirect()->route('step_2', $request); // <- Error happens here. Missing required parameters for [Route: step_2]
}
Step 2 (blade)
/**
* Returns a view to confirm the output from step 1.
*
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function step_2(Request $request) {
.....
}
Routes:
Route::prefix('refer')->group(function () {
// Step 1
Route::get('/', ['uses' => 'ReferController@step_1', 'as' => 'step_1']);
Route::post('/', ['uses' => 'ReferController@step1_request']);
// Step 2
Route::get('step/2', ['uses' => 'ReferController@step_2', 'as' => 'step_2']);
Route::post('/step/2', ['uses' => 'ReferController@step2_request']);
// Step 3
Route::get('step/3', ['uses' => 'ReferController@step3', 'as' => 'step_3']);
Route::post('step/3', ['uses' => 'ReferController@step3_request']);
});
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire