Column not found: 1054 Unknown column 'tbl_destinations.id' PDOException in 'where clause': SQLSTATE: Rewritten in /var/www/html/...Connection.php:338 as: Column not found :1054 Database exception for unknown column 'tbl_destinations.id' in 'where clause'
P粉677573079
P粉677573079 2023-12-12 22:07:26
0
1
451

The id field in my database is des_id, how can I change it to 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
    ]);
});

P粉677573079
P粉677573079

reply all(1)
P粉458725040

Your code looks fine to me.

Try setting this in your target model:

protected $primaryKey = 'des_id';
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!