relationOrders('id_delivery_note') ; } /** * Retourne les options de base nécessaires à la fonction de recherche. * * @return array */ public static function defaultOptionsSearch() { return [ 'with' => [], 'join_with' => ['user AS user_delivery_note', 'orders', 'producer'], 'orderby' => 'date ASC', 'attribute_id_producer' => 'delivery_note.id_producer' ]; } public function getInvoiceId() { if($this->orders && count($this->orders) > 0) { foreach($this->orders as $order) { if($order->id_invoice) { return $order->id_invoice; } } } return false; } public function isInvoiced() { return (bool) $this->getInvoiceId(); } public function getInvoice() { $invoice = null; $idInvoice = $this->getInvoiceId(); if($idInvoice) { $invoice = Invoice::searchOne([ 'id' => $idInvoice ]); } return $invoice; } }