0

I want to update my data with Laravel so I used the PATCH method but I have an error :

Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException The GET method is not supported for route checkPermissions. Supported methods: PATCH.

I used PATCH method like this :

My view :

    <form action="/checkPermissions" method="PATCH">
    @method('PATCH')
    @csrf

      //My fields are here

    </form>

My route :

Route::patch('/checkPermissions', [MyController::class, 'check']);

(I already check this Question The GET method is not supported for this route. Supported methods: PATCH, but there is no answers that solve the problem)

If you need to see more code or files just ask me.

Thanks for your help !

1
  • 1
    method="POST" instead of method="PATCH" Commented Mar 28, 2023 at 8:28

1 Answer 1

3

Form actions are only supported to get and post actions. Change the form action to post and you are already defined patch within the @method directive.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks ! I don't really understand the logic... We have to set the method to POST to be able to execute a PATCH...
you cannot use PUT/PATCH - there's just no such methods supported by forms in browsers - it's only GET and POST. So how does Laravel make it work with @method('patch'). under the hood laravel constructs a hidden field with name _method and then checks it upon form submittion, routing it to the correct Controller method. Hope this clears out the confusion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.