I am using CoreUI and Laravel to build a project and I want to make a form on clients/addclient which will pass all the data from form to my database.
I am struggling into this part:
I have these routes on web.php:
JavaScript
x
Route::group(['prefix' => 'clients'], function(){
Route::get('addclient', 'ClientController@index');
Route::post('submit','ClientController@save');
Route::get('viewclient', function () { return view('pages.clients.viewclient'); });
Route::get('products', function () { return view('pages.clients.products'); });
});
I have a file called addclient.blade.php with this form tag:
JavaScript
<form action="{{url('clients/submit')}}" method="POST">
and on ClientController I have made this function just for testing that I get the data back:
JavaScript
function save(Request $req){
print_r($req->input());
}
what am I doing wrong and I dont see any results?
thanks
Advertisement
Answer
try this
JavaScript
Route::group(['prefix' => 'clients'], function(){
Route::get('addclient', 'ClientController@index')->name('addclient');
Route::post('submit','ClientController@save')->name('submit');
Route::get('viewclient', function () { return view('pages.clients.viewclient'); });
Route::get('products', function () { return view('pages.clients.products'); });
});
in form
JavaScript
<form action="{{route('clients.submit')}}" method="POST">
you can see list group route :
JavaScript
php artisan route:list