hasOne(User::className(), ['id' => 'id_user']); } public function relationOrders($fieldIdDocument) { $defaultOptionsSearch = Order::defaultOptionsSearch(); return $this->hasMany(Order::className(), [$fieldIdDocument => 'id']) ->with($defaultOptionsSearch['with']) ->joinWith($defaultOptionsSearch['join_with']); } /* * Méthodes */ public function getAmount($type = Order::AMOUNT_TOTAL, $format = false) { $amount = 0; $ordersArray = $this->orders; foreach ($ordersArray as $order) { $order->init(); $amount += $order->getAmount($type); } if ($format) { return Price::format($amount); } else { return $amount; } } public function getPointSale() { if(isset($this->orders) && isset($this->orders[0])) { return $this->orders[0]->pointSale ; } else { return '' ; } } public function getDistribution() { if(isset($this->orders) && isset($this->orders[0])) { return $this->orders[0]->distribution; } else { return '' ; } } }