I am not getting how to pass data to the controller to update data, below I have given code.
// below is my jquery which I am using to pass form data to the controller.
function editProfile(profileData){ $("#profile_name").val(profileData.name) $("#profile_id").val(profileData.id); $("#profile-modal-lg").modal('show'); $("#profile-form").attr('action',"text/edit/"+profileData.id); }
// below is my route
Route::post('text/edit/{profile}', 'profileController@editProfileData')->name('profile.edit');
// inside controller I am having a function called edit profile
public function editProfileData(Profile $profile,profileRequest $request){ $profile->update($request->all()); return redirect()->back(); }
Advertisement
Answer
Is your form method set to ‘POST’? If not, try setting the form method attribute to ‘POST’. You might also want to add slash at the start of your url to target the absolute url.
$("#profile-form") .attr('method', 'POST') .attr('action', `/text/edit/${profileData.id}`);