I have a conference details page where the user can select in a form the quantity of tickets for the conference that he wants. So this form has this action:
<form method="post"
action="{{route('conferences.storeQuantities',
['id' => $conference->id, 'slug' => $conference->slug])}}">
...
</form>
So when the user clicks in "Next" the code goes to the RegistrationController storeQuantities() method that stores the selected tickets, stores some info in the session and returns the user to the registration route:
// summary of the storeQuantities()
public function storeQuantities(Request $request, $id, $slug = null)
{
$allParticipants = Confernece::where('id', $id)->first()->all_participants;
....
Session::put('selectedRtypes', $selectedRtypes);
Session::put('allParticipants', $allParticipants);
return redirect(route('conferences.registration', ['id' => $id, 'slug' => $slug]))->with('total', $total);
}
So then the code goes to the route:
Route::get('/conference/{id}/{slug?}/registration', [
'uses' => 'RegistrationController@displayRegistrationPage',
'as' =>'conferences.registration'
]);
And with the above route the function displayRegistrationPage is called that gets the values in session that are necessary to show in the registration page and redirects the user to the registration page:
public function displayRegistrationPage(Request $request, $id, $slug = null)
{
$selectedRtypes = Session::get('selectedRtypes');
$allParticipants = Session::get('allParticipants');
return view('conferences.registration',
['selectedRtypes' => $selectedRtypes, 'allParticipants' => $allParticipants, 'customQuestions' => $customQuestions, 'id' => $id,
'slug' => $slug]);
}
Now in the registration.blade.php I have a form for the user introduce some data so he can register in a conference. When the form is submited the code should go to the RegistrationController storeRegistration(), so I have this action:
<form method="post"
action="{{route('conferences.storeRegistration', ['id' => $conference->id])}}">
...
</form>
And this route:
Route::post('/conference/{id}/{slug?}/registration/storeRegistration', [
'uses' => 'RegistrationController@storeRegistration',
'as' =>'conferences.storeRegistration'
]);
But it appears the error "Undefined variable: conference
". Do you know how to solve the issue?