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

Missing required parameters for [Route: photographers.edit] [URI: posts/edit/{photographers}]

I Get this error every time I create an edit button or even a button to view a particular post in my project.

Here’s my route code:

Route::get('/posts/edit/{photographers}', 'PhotographerController@edit')
    ->name('photographers.edit');

Here’s my edit function in the controller file :

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 edit(Photographer $photographer)
        {
            return view('photographers.edit', compact('photographer'));
        }

Here’s my view button route:

<a href="{{route('photographers.edit', $photographer)}}">Edit</a>

I read a lot of previous posts on this issue but didn’t really help me.

>Solution :

sometimes the dependency injection can be the cause of the error, you can use id as follows

public function edit($id)
    {
        $photographer = Photographer::find($id);

        return view('photographers.edit', compact('photographer'));
    }

I also noticed in your blade file, you are passing the entire $photographer as an argument, you only need to pass the id

<a href="{{route('photographers.edit', $photographer->id)}}">Edit</a>
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