DarrylDeschene's avatar

Laravel Inertia The Patch method is not supported

Hello All

I'm building an Inertia app and am having issues with the update.

here is the component:

const form = useForm({
    _method: 'patch',
    name: null,
    description: null,
    uuid: null
})

const props = defineProps({
    player: {
        type: Object,
        required: true
    }
})

onMounted(() => {
    form.name = props.player.name
    form.description = props.player.description
    form.uuid = props.player.uuid
})

function submit() {
    form.post('/digital-signage/players', form)
}

Here is the route file ,

      Route::get('/players' , [PlayerController::class, 'index'])->name('digital-signage/players');
        Route::patch('/players/{player}' , [PlayerController::class, 'update'])->name('digital-signage/players/update');
        Route::get('/players/create' , [PlayerController::class, 'create'])->name('digital-signage/players/create');
        Route::post('/players' , [PlayerController::class, 'store'])->name('digital-signage/players/store');
        Route::get('/players/{player}' , [PlayerController::class, 'show'])->name('digital-signage/players/show');
        Route::get('/players/{player}/edit' , [PlayerController::class, 'edit'])->name('digital-signage/players/edit');
        Route::delete('/players/{player}' , [PlayerController::class, 'destroy'])->name('digital-signage/players/destroy');

and the error: The PATCH method is not supported for route digital-signage/players. Supported methods: GET, HEAD, POST.

not sure what I'm doing wrong, I've tried to change the route from patch to post, and have run optimize to clear the caches.

0 likes
2 replies
Nakov's avatar
Nakov
Best Answer
Level 73

So in your route the endpoint for the patch request is defined like this '/players/{player}' and yet, you try to send a patch request without providing the player which you are trying to update..

    form.post('/digital-signage/players/' + props.player.id, form)
1 like

Please or to participate in this conversation.