我有一个问题,我一直在开发laravel应用程序,我遇到了这个奇怪的错误:
QueryException in Connection.php line 770:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`testenv`.`products`, CONSTRAINT `products_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`)) (SQL: insert into `products` () values ())
Run Code Online (Sandbox Code Playgroud)
这是我的商店功能
public function store(Request $request)
{
$product = new Product;
/*
$product->name = $request->name;
$product->stockQty = $request->stockQty;
$product->minimumQty = $request->minimumQty;
$product->description = $request->description;
$product->notes = $request->notes;
$product->tenantMargin = $request->tenantMargin;
$product->length = $request->length;
$product->height = $request->height;
$product->weight = $request->weight;
$product->showLength = $request->showLength; …Run Code Online (Sandbox Code Playgroud)