id.' ),0) as billed_amount ')->first()->billed_amount ?? 0; } public function budgetPlan() { return $this->belongsTo(BudgetPlan::class); } public function getCustomerNameAttribute() { return ($this->order->customer_name ?? $this->budgetPlan->order->customer_name ?? "-") . " - " . ($this->order->customer_phone ?? $this->budgetPlan->order->customer_phone ?? "-"); } public function getCustomerPhoneAttribute() { return $this->order->customer_phone ?? $this->budgetPlan->order->customer_phone ?? "-"; } public function getCurrentStatusAttribute() { if ($this->invoice) { return 'closed'; } return 'open'; } public function invoice() { return $this->setConnection('mysql')->hasOne(Invoice::class)->withoutGlobalScopes(); } public function getAddressAttribute() { return $this->budgetPlan->order->full_address ?? "-"; } public function tax() { return $this->setConnection('mysql')->belongsTo(Tax::class)->select('id', 'name', 'rate'); } }