我有3个表,产品,图像和product_image.第三个是旋转表.除了PRODUCT_ID和image_id在product_image表,我也有在该转动表2个额外的字段:位置和类型,现在现有的产品型号A,我怎么把图像附A和设立,同时位置和该转轴记录中的类型值?谢谢.
Raz*_*zor 23
你可以尝试这样的事情:
$product = Product::find(1);
// if you need also to save the image
$image = new Image(array('foo' => 'bar'));
$product->images()->save($image,array('position'=>'foo', 'type'=>'bar' ));
// if you know image id
$product->images()->attach([$imageId => ['position'=>'foo', 'type'=>'bar']]);
| 归档时间: | 
 | 
| 查看次数: | 10131 次 | 
| 最近记录: |