How to use patch request in Laravel?

后端 未结 3 1117
清歌不尽
清歌不尽 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:05

    Yes, you need to send id for route patch. Example from https://laravel.com/docs/5.4/controllers#resource-controllers for Laravel

    PUT/PATCH - /photos/{photo}, so you don't need update word in your route. Just users/id and methods PUT or PATCH.

    UPD for CRUD operations:

    // Routes
    Route::resource('items', 'ItemsController');
    
    // Form for update item with id=1
    
    {!! csrf_field() !!}
    // Controller public function update($id, Request $request) { // Validation here $item = Item::findOrFail($id); // Update here }

提交回复
热议问题