diff --git a/app/Classes/Modules/Orders/Services/ListsOrderHistory.php b/app/Classes/Modules/Orders/Services/ListsOrderHistory.php index 663b3cc..9088992 100644 --- a/app/Classes/Modules/Orders/Services/ListsOrderHistory.php +++ b/app/Classes/Modules/Orders/Services/ListsOrderHistory.php @@ -34,22 +34,20 @@ class ListsOrderHistory $this->history->push(['type' => 1, 'date' => $createdAt->format('d-m-Y'), 'description' => 'Order number has been created']); - + $warehouse_id = OrderWarehouse::where('order_id', $orderId)->first()->warehouse_id; + $warehouse = Warehouse::where('id', $warehouse_id)->first(); foreach ($orderSteps as $step){ $completeDate = Carbon::parse($step->complete_date)->format('d-m-Y'); switch ($step->reference_id){ case OrderSteps::ORDER_PROCESSING_STEP: - $warehous = OrderWarehouse::where('order_id', $orderId)->first(); - if($warehous){ - $this->history->push(['type' => 1, 'date' => $completeDate, 'description' => Warehouse::where('id', $warehous->warehouse_id)->first()->name.' confirmed as your order\'s warehouse']); + if($warehouse_id){ + $this->history->push(['type' => 1, 'date' => $completeDate, 'description' => $warehouse->name.' confirmed as your order\'s warehouse']); } break; case OrderSteps::ORDER_NO_WAREHOUSE_PENDING_SUPPLIER: $this->history->push(['type' => 1, 'date' => $completeDate, 'description' => 'Your Order has been loaded into container']); break; case OrderSteps::ORDER_WAREHOUSE_RECEIVING_STEP: - $warehouseId = OrderWarehouse::where('order_id', $order->id)->where('type', 0)->first()->pluck('warehouse_id'); - $warehouse = Warehouse::where('id', $warehouseId)->first(); $this->history->push(['type' => 1, 'date' => $completeDate, 'description' => 'Arrived at '. $warehouse->name .' warehouse in china']); break; case OrderSteps::ORDER_WAREHOUSE_PACKING_STEP: