How to use patch request in Laravel?

后端 未结 3 1113
清歌不尽
清歌不尽 2021-02-04 07:44

There is entity User that is stoted in table Users

Some fields in this table are null by default.

I need to update these fields and se

3条回答
  •  一向
    一向 (楼主)
    2021-02-04 08:04

    your route is:

    Route::patch('users/update', 'UsersController@update');
    

    replace your route with following route that use for all CRUD opration:

    Route::resource('users', 'UsersController');
    

    if you use ajax for submit data then replace your type and url with following:

    type: "patch",
    url: "{{url('/')}}users/" + id,
    

    if you don't use ajax than use following:

    {{csrf_field()}} {{ method_field('PATCH') }}

    update: after version 5.6 you can use these syntax for above functions in any blade file:

提交回复
热议问题