How does Laravel handle PUT requests from browsers?

后端 未结 6 1399
Happy的楠姐
Happy的楠姐 2020-12-20 12:17

I know browsers only support POST and GET requests, and Laravel supports PUT requests using the following code:



        
6条回答
  •  不思量自难忘°
    2020-12-20 12:55

    PUT usually refers to update request.

    When you open a form inside laravel blade template using,

    {{ Form::open('/path/', 'PUT') }}
    

    It would create a hidden field inside the form as follows,

    
    

    In order for you to process the PUT request inside your controller, you would need to create a method with a put prefix,

    for example, putMethodName()
    

    so if you specify,

    {{ Form::open('controller/methodName/', 'PUT') }}
    

    inside Form:open. Then you would need to create a controller method as follows,

    class Controller extends BaseController {
        public function putMethodName()
        {
            // put - usual update code logic goes here
        }
    }
    

提交回复
热议问题