Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

BoomCheeseBurge's avatar

404 Not Found using PATCH method on Inertia's Router method

I am using Laravel 11 with InertiaJs 2.0.0 and ReactJs 18.2.0 for my personal project. I am trying to send a PATCH web request to restore a soft deleted model. I cannot figure out why I fail to send the web request to the specified controller.

Note: I probably should not use patch, so please suggest me the appropriate HTTP method if I am not using the correct one. thanks.

Tried solutions so far:

  • Switching to POST or PUT method.
  • Tried running the 'php artisan optimize:clear' command and then restarting the server.
  • Replacing the route model binding with an integer parameter.

However, the tried solutions above always output the same error of 404 Not Found.

JSX Code

Here is the JSX code that initiates the web request.

router.patch(route('project.restore', projectId));

'projectId' here is just a state variable that contains an integer value.

Web Route

    Route::patch('/project/restore/{project}', [ProjectController::class, 'restore'])->name('project.restore');
    Route::resource('/project', ProjectController::class);

I have placed the custom controller above the resource controller to avoid conflict.

Controller

    public function restore(Project $project)
    {
        dd($project->name);

Any help or suggestions would be helpful, thanks!

0 likes
0 replies

Please or to participate in this conversation.