小编Arg*_*tya的帖子

Laravel保存($ request-> all())错误

我有一个问题,我一直在开发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)

php sql laravel laravel-5 laravel-5.3

4
推荐指数
1
解决办法
6846
查看次数

标签 统计

laravel ×1

laravel-5 ×1

laravel-5.3 ×1

php ×1

sql ×1