Spalte nicht gefunden: 1054 Unbekannte Spalte „tbl_destinations.id' PDOException in „where-Klausel': SQLSTATE: In /var/www/html/...Connection.php:338 umgeschrieben als: Spalte nicht gefunden: 1054 Datenbankausnahme für unbekannte Spalte „tbl_destinations.id' in „where-Klausel'
P粉677573079
P粉677573079 2023-12-12 22:07:26
0
1
448

Das ID-Feld in meiner Datenbank ist des_id. Wie kann ich es in des_id ändern?

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
    ]);
});

P粉677573079
P粉677573079

Antworte allen(1)
P粉458725040

你的代码对我来说看起来不错。

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

protected $primaryKey = 'des_id';
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!