I have output object $product after inserting data into table Product:
$product = Product::create($data);
In model Product I have:
public function images()
{
return $this->hasMany("App\ProductImage");
}
The I try to add images to table product_images:
$product->images()->save(new ProductImage(UploadFiles::$files));
Relationship beetwen tables is product.id = product_images.
So, after inserting I get message:
General error: 1364 Field 'image' doesn't have a default value (SQL: insert into `product_images` (`product_id`) values (21))
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire