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

Laravel : Missing required parameter for [Route: Region.update]

I encounter a problem on Laravel, I followed the Bootcamp step by step and it was nice, very clear I finished it entirely,

I’m facing trouble when I try to reproduce it on a project of my own, everything goes cool until I try to implement the "edit" part see: https://bootcamp.laravel.com/blade/editing-chirps

I’m getting this error : Missing required parameter for [Route: Region.update]

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

I’ve been looking for some times but didn’t find anything that worked for me, here is the code :

Controller :

public function edit(Region $region)
    {
        return view('regions.edit', [
            'region' => $region,
        ]);
    }

public function index()
    {
        $regions = Region::all();

        return view('regions.index', [
            'regions' => $regions,
        ]);
    }

public function update(Request $request, Region $region)
    {
        $validated = $request->validate([
            'name' => 'required|string|max:255',
        ]);
 
        $region->update($validated);
 
        return redirect(route('Region.index'));
    }

Index view where I’m passing the data :

<x-dropdown-link :href="route('Region.edit', $region)">
   <img src={{url("build/img/edit.png")}} width="40">
</x-dropdown-link>

Edit view specifically where problems happens.

<form method="POST" action="{{ route('Region.update', $region) }}">

Web route file

Route::resource('Region',RegionController::class)
    ->only(['index', 'create', 'store', 'edit', 'update'])
    ->middleware(['auth', 'verified']);

When I click the link in the index view, I’m redirect on the right link : http://localhost/Region/5/edit ( 5 is an exemple of id ).

But the error from the title appears.

I tried this because I read it here :

<form method="POST" action="{{ route('Region.update', ['Region' => $region]) }}">

But it didn’t change anything.

Any help would be really appreciate.
Thank you for advance

>Solution :

Laravel Resource is case sensitive I think… So, we need to name parameter converter with uppercase like in resource name.

public function edit(Region $Region);

public function update(Request $request, Region $Region);
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