Laravel attach with extra field Laravel attach with extra field laravel laravel

Laravel attach with extra field


You may try something like this:

$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']]);