PDOException:SQLSTATE[42S22]:未找到列:1054 'where clause' 中 'tbl_destinations.id' 中的未知列 /var/www/html/...Connection.php:338

PDOException:SQLSTATE[42S22]:Column not found: 1054 Unknown column 'tbl_destinations.id' in 'where clause' in /var/www/html/...Connection.php:338

我数据库中的 id 字段是 des_id ,如何将其更改为 des_id?

Route::post('Itest/LoadSuppliers', function (Request $request) {
    $request->validate([
        'destination_id' => 'required|exists:mysql.tbl_destinations,des_id',
        'from' => 'required|numeric|min:0',
        'to' => 'required|numeric|min:0',
    ]);
    $destination_id = Destination::where('des_id','=', $request->destination_id)->firstOrFail();
    $from = $request->from;
    $to = $request->to;
    dispatch(new TestJob($destination_id, $from, $to));
    return response()->json([
        'status' => true
    ]);
});

我觉得你的代码不错。

尝试在您的目标模型中进行设置:

protected $primaryKey = 'des_id';