2 回答

TA貢獻1936條經驗 獲得超7個贊
試試這個:
$dbProduct->delete();
Brand::where('product_id', $dbProduct->id)->delete();
Tags::where('product_id', $dbProduct->id)->delete();
并添加所有表

TA貢獻1829條經驗 獲得超7個贊
這是我到達的解決方案:
ini_set('max_execution_time', 300);
$products = $request->all();
try {
DB::beginTransaction();
foreach ($products as $product) {
$product = $this->getProduct($product['SKU']);
$product->sizes()->detach();
$product->tags()->detach();
$product->fields()->detach();
$product->countries()->detach();
$product->exportationFactors()->delete();
$product->delete();
DB::commit();
}
DB::commit();
} catch (Exception $e) {
DB::rollBack();
throw new HttpException(500, 'Sucedio un error eliminando la información favor intentar de nuevo');
}
在 vue.js 中
sendData(data, index) {
this.loading = true;
this.error = {};
this.$http.post(this.baseUrl, data, this.params)
.then(
() => {
this.successAction();
this.statuses[index] = 1;
this.errorDis = false;
},
(res) => {
this.showErrors(res);
this.statuses[index] = 2;
this.errorDis = true;
}
);
},
- 2 回答
- 0 關注
- 181 瀏覽
添加回答
舉報