Reputation: 533
I am facing this error:
ErrorException (E_ERROR) Route [projects.adduser] not defined. (View: E:\wamp64\www\pmanagement\resources\views\projects\show.blade.php)
My route is defined in the HTML below:
<form id="add-user" action="{{ route('projects.adduser',[$project->id]) }}" method="POST">
and this is my route code:
Route::post('projects/adduser/{project_id?}','ProjectsController@adduser');
Upvotes: 1
Views: 1019
Reputation: 163748
You need to name the route:
Route::post('projects/adduser/{project_id?}', 'ProjectsController@adduser')->name('projects.adduser');
Or you could use the url()
helper instead of route()
:
url('projects/adduser/' . $project->id)
Upvotes: 4
Reputation: 114
You need to name your route to use it like that, for example:
Route::post('projects/adduser/{project_id?}')
->uses('ProjectsController@adduser')
->name('projects.adduser');
Named routes: https://laravel.com/docs/5.5/routing#named-routes
Upvotes: 1