Illuminate \ Database \ QueryException (42S22) SQLSTATE[42S22]: Column not found: 1054 Unknown column 'produk.id' in 'where clause' (SQL: select * from
produkwhereproduk.id= 65 limit 1)
Не знаю где ошибка после моего кода, который показывает ошибку:
public function update(Request $request, $id)
{
$this->validate($request, $this->aturan, $this->pesan);
$produk = produk::find($id);
$produk->nama_produk = $request['nama'];
$produk->id_kategori = $request['kategori'];
$produk->harga_jual = $request['harga'];
$produk->update();
return Redirect::route('produk.index');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$produk = Produk::find($id);
$produk->delete();
return Redirect::route('produk.index');
}






Согласно документации Eloquent, если ваша модель использует другой первичный ключ, чем id, вы должны это настроить. Eloquent ожидает, что первичным ключом будет id, и что по умолчанию это целое число с автоинкрементом.
YourModel extends Eloquent ...
{
protected $primaryKey = 'yourOtherKey';
...
}
"Eloquent will also assume that each table has a primary key column named
id. You may define a protected$primaryKeyproperty to override this convention.""In addition, Eloquent assumes that the primary key is an incrementing integer value, which means that by default the primary key will be cast to an
intautomatically. If you wish to use a non-incrementing or a non-numeric primary key you must set the public$incrementingproperty on your model tofalse. If your primary key is not an integer, you should set the protected$keyTypeproperty on your model tostring."
попробуйте вместо этого findOrFail
$produk = produk::findOrFail($id);
Можете ли вы поделиться своей схемой таблицы mysql (SHOW CREATE TABLE)?