1 回答
TA贡献1155条经验 获得超0个赞
尝试这个:
private $productWithError;
public function index(Order $order,Request $request)
{
if($request->status == 'approved'){
if( ! $this->check($order) ) {
return redirect()->back()
->with('error', $this->productWithError.' '.trans('site.larger_than_qty_in_store'));
}
}
$this->updateOrder($order,$request);
return redirect()->back()
->with('success',trans('site.message_updated'));
}
protected function check($order){
foreach($order->products as $product){
if ($product->doesNotHaveEnoughQuantity($product->pivot->quantity)) {
$this->productWithError = $product->name;
return false;
}
$this->updateProductQty($product);
}
return true;
}
- 1 回答
- 0 关注
- 102 浏览
添加回答
举报