我遇到了这个错误:
SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value: '808498e7-a393-42f1-ab23-6ee89eb7040a'
在尝试通过关系删除记录时,使用以下方法:
$delivery->stockMovements()->delete();
原始查询显示为:
delete from `stock_movements` where `stock_movements`.`entity_id` = 10000005 and `stock_movements`.`entity_id` is not null and `stock_movements`.`company_id` = 8b11050c-612c-4922-8b34-d04d579e02a9
我已经搜索了很多,但是除了可能与强制转换错误有关之外,找不到任何具体的内容。也许与UUID有关?
迁移如下:
Schema::create('deliveries', function (Blueprint $table) {
$table->increments('id');
$table->uuid('company_id');
$table->string('delivery_type');
$table->string('supplier_name');
$table->string('supplier_ref')->nullable();
$table->string('merchant_ref')->nullable();
$table->string('carrier_name')->nullable();
$table->string('status');
$table->date('expected_delivery');
$table->dateTime('completed_at')->nullable();
$table->timestamps();
});
Schema::create('stock_movements', function (Blueprint $table) {
$table->increments('id');
$table->uuid('company_id');
$table->uuid('product_id');
$table->string('entity_type'); //can be order / delivery
$table->string('entity_id'); //can be UUID / String / Integer
$table->string('location_id')->nullable(); // can be warehouse_location / shipment_package / delivery_container
$table->string('action')->default('');
$table->integer('qty')->default(0);
$table->timestamps();
});