/**
  * @param $purchase_id
  * @return array
  */
 public static function getOrdersCollectionsByPurchaseIdAndByUserId($purchase_id, $user_id)
 {
     $orders = \DB::table(\App\Basket::TABLE_PRODUCTS_IN_BASKETS)->select('*')->where('user_id', '=', $user_id)->where('purchase_id', '=', $purchase_id)->get();
     $user = \App\User::find($user_id);
     \App\Helpers\Assistant::assertModel($user);
     $orders_models = $user->orders()->where('purchase_id', '=', $purchase_id)->get();
     if (!$orders_models->count()) {
         return [];
     }
     $orders_collections_arr = [];
     foreach ($orders_models as $order_model) {
         $order_collection = new \stdClass();
         $order_collection->order_id = $order_model->id;
         $order_collection->amount = $order_model->amount;
         $order_collection->purchase_id = $order_model->purchase_id;
         $order_collection->product_id = $order_model->product_id;
         $order_collection->product_in_purchase_id = $order_model->product_in_purchase_id;
         $product_in_purchase_model = \App\Models\ProductInPurchaseModel::find($order_model->product_in_purchase_id);
         \App\Helpers\Assistant::assertModel($product_in_purchase_model);
         $current_max_price = $product_in_purchase_model->getMaxPrice();
         $order_collection->product_price = $current_max_price;
         $order_collection->total_price = number_format(\App\Helpers\OrdersHelper::getTotalPrice($current_max_price, $order_model->amount), 2);
         $order_collection->product_name = $product_in_purchase_model->product->name;
         $order_collection->product_alias = $product_in_purchase_model->alias();
         $orders_collections_arr[] = $order_collection;
     }
     return $orders_collections_arr;
 }
 public function getIndex()
 {
     $purchases_ids_arr = \App\Helpers\OrdersHelper::getPurchasesIdsArrByUserId($this->user->id);
     /**
      * TODO: заменить на \App\Helpers\OrdersHelper::getOrdersCollectionsByPurchaseIdAndByUserId
      */
     $orders_models_arr_by_purchases_ids_arr = \App\Helpers\OrdersHelper::getOrdersModelsArrByPurchasesIdsArrAndByUserId($this->user->id, $purchases_ids_arr);
     return view('orders.index', ['purchases_ids_arr' => $purchases_ids_arr, 'orders_models_arr_by_purchases_ids_arr' => $orders_models_arr_by_purchases_ids_arr]);
 }