Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

send entity for controller not working, php laravel 7

in blade template

<form action="{{ route('leads.courses.restore', $lead->id) }}" method="POST">
  @csrf
  <button type="submit">
    Restore 
  </button>
</form>

in routes

Route::post('leads/courses/{lead}/restore', 'LeadsCoursesController@restore')->name('leads.courses.restore');

in controller

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

public function restore(Lead $lead)
  {
    dd("ok");
  }

but i receive HTTP code 404, if i remove the parameter in controller receive "ok".

>Solution :

This problem happens because you try to find a soft deleted record so to fix it add to your route withTrashed() to be like this

Route::post('leads/courses/{lead}/restore', 'LeadsCoursesController@restore')
   ->withTrashed()
   ->name('leads.courses.restore');

for more info check this part in docs

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading