【发布时间】:2019-06-30 11:19:40
【问题描述】:
我正在尝试使用隐藏输入从数据库中获取产品 ID,但被卡住了;我收到错误General error: 1366 Incorrect integer value: '[{"id":1}]' for column 'product_id'。如何从数据库中获取产品 ID?
刀片
<input type="hidden" name="id" value="" />
控制器
Image::create(array_merge($formInput,
[
$id = $request->input('id'),
$product_id = Product::find('id'),
'product_id' => $product_id,
]));
更新
这是我更新的控制器。
Image::create(array_merge($formInput,
[
$id = $request->input('id'),
$product = Product::get($id),
'product_id' =>$product->id,
]));
【问题讨论】:
-
$product_id=Product::get('id'),应该是`$product_id=Product::select('id')->get(),` -
这也会引发错误
Property [id] does not exist on this collection instance.@DhananjayKyada
标签: php mysql laravel laravel-5