php - laravel FormBuilder getMethod issue
942
The getMethod function implementation does not accept all HTTP verbs exceptPOST
,GET
?
My use case is this
- Form open to an update resource, so method should be
PUT
. - I built one access control library to check if the user has access to the { resource, method }
- I am using
getMethod()
to get method name, but it always returnsPOST
even if the parameter sent isPUT
. - As this is returning
POST
always,ACL
always returnsNO_ACCESS
Any reason whygetMethod()
is written this way?
Answer
Solution:
First, I would check to make sure your web server allows PUT requests. I had an issue with the web server only allowing GET and POST by default.
I'm assuming you're doing something like
if( Request::getMethod() == 'POST' )
?Since laravel's Request class extends Symfony's you can try using
Request::isMethod('post')
. This is my preference and it reads better IMO.