Ollie1700
2 years ago

Route Model Binding produces 404, even though route exists

Posted 2 years ago by Ollie1700

Hi there, I'm hoping to get some help on this problem that is baffling me. I'm tearing my hair out!

I am making basic CMS, and have this route:

Route::post('/cms/menu-item/{id}/edit', '[email protected]');

And in my CMSController:

public function editMenuItem(Request $request, $id)
    {
        // Validate, save and do other stuff....

        // Redirect
        return redirect('/admin/cms/header/edit');
    }

When I submit my form that is pointed to that route, I get a 404. However, if I change my route to look like this:

Route::post('/cms/menu-item/{id}/edit', function($id) {
    dd("AHHHH");
});

I get the dd output...

What on Earth am I missing here? The route path is correct, and submits to the correct location, since the dd output appears when I use a closure, rather than a reference to the controller. But when I use the controller, it just 404s

Does anyone have any ideas?

Thanks in advance to anyone who can shed some light on this.

Please sign in or create an account to participate in this conversation.