更新数据 API 在 Postman 中不起作用错误说列 'nama_pelanggan' 不能为空

update data API not working in Postman the error said Column 'nama_pelanggan' cannot be null

我的代码有问题 API laravel 8 更新数据,我认为我的代码是正确的,我不知道错误在哪里,是不是我的错误代码或者我在更新数据时错了这是代码 控制器

 public function update(Request $request, $id)
    {
        $cek_pelanggan = DaftarPelanggan::firstWhere('id', $id);
        if ($cek_pelanggan) {
            $data_pelanggan = DaftarPelanggan::find($id);
            $data_pelanggan->nama_pelanggan = $request->nama_pelanggan;
            $data_pelanggan->alamat = $request->alamat;
            $data_pelanggan->no_telp = $request->no_telp;
            $data_pelanggan->diskon_id = $request->diskon_id;
            $data_pelanggan->save();
            return response([
                'status' => 'OK',
                'message' => 'Data Pelanggan Berhasil Diubah',
                'data' => $data_pelanggan
            ], 200);
        } else {
            return response([
                'status' => 'Not Found',
                'message' => 'Data Tidak Ditemukan',
            ], 404);
        }
    }

这是模型

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Laravel\Sanctum\HasApitokens;

class DaftarPelanggan extends Model
{
    use HasFactory, HasApitokens;
    
    protected $table = "daftar_pelanggans";
    protected $primaryKey='id';
    protected $fillable = ['nama_pelanggan','alamat','no_telp','diskon_id'];

    public function diskon(){
    return $this->belongsTo(Diskon::class,'diskon_id')->withDefault([
        'nama_member' => 'Guest',
    ]);
   }

}

这是路线

Route::group(['middleware' => ['auth:sanctum']], function () {
    Route::get('auth/me', 'App\Http\Controllers\Auth\AuthController@me');
    Route::post('auth/logout', 'App\Http\Controllers\Auth\AuthController@logout');
    Route::get('/daftar_pelanggan', 'App\Http\Controllers\API\DaftarPelangganController@index');
    Route::post('/daftar_pelanggan/create', 'App\Http\Controllers\API\DaftarPelangganController@create');
    Route::put('/daftar_pelanggan/update/{id}', 'App\Http\Controllers\API\DaftarPelangganController@update');
    Route::delete('/daftar_pelanggan/delete/{id}', 'App\Http\Controllers\API\DaftarPelangganController@delete');
});

这是我更新数据时的邮递员

请将表单数据更改为 x-www-form-urlencoded。

嗨,朋友,问题是 $request->nama_pelanggan 变得空了。请尝试获取如下

$data_pelanggan->nama_pelanggan = $request->get('nama_pelanggan'); //other columns as like this

谢谢,祝你有愉快的一天