Reputation: 323
This does not work:
return redirect('/view-project-team/' . $projectRequest->id );
What is the right way to pass a variable into the route in this context?
Upvotes: 1
Views: 1175
Reputation: 460
As was said in comments you should use name of the route:
return redirect()->route('view.project.team', ['id' => $projectRequest->id]);
Names can be defined in your router:
Route::get('/view-project-team/{id}', 'YourController@yourHandler')->name('view.project.team');
Note that:
'id'
in route()
call is refer to {id}
in Route::get()
call (names must match).Upvotes: 5