resource; return [ 'id' => $estimate->id, 'estimate_date' => $estimate->estimate_date, 'expiry_date' => $estimate->expiry_date, 'estimate_number' => $estimate->estimate_number, 'status' => $estimate->status, 'reference_number' => $estimate->reference_number, 'tax_per_item' => $estimate->tax_per_item, 'tax_included' => $estimate->tax_included, 'discount_per_item' => $estimate->discount_per_item, 'notes' => $estimate->getNotes(), 'discount' => $estimate->discount, 'discount_type' => $estimate->discount_type, 'discount_val' => $estimate->discount_val, 'sub_total' => $estimate->sub_total, 'total' => $estimate->total, 'tax' => $estimate->tax, 'unique_hash' => $estimate->unique_hash, 'creator_id' => $estimate->creator_id, 'template_name' => $estimate->template_name, 'customer_id' => $estimate->customer_id, 'exchange_rate' => $estimate->exchange_rate, 'base_discount_val' => $estimate->base_discount_val, 'base_sub_total' => $estimate->base_sub_total, 'base_total' => $estimate->base_total, 'base_tax' => $estimate->base_tax, 'sequence_number' => $estimate->sequence_number, 'currency_id' => $estimate->currency_id, 'formatted_expiry_date' => $estimate->formattedExpiryDate, 'formatted_estimate_date' => $estimate->formattedEstimateDate, 'estimate_pdf_url' => $estimate->estimatePdfUrl, 'sales_tax_type' => $estimate->sales_tax_type, 'sales_tax_address_type' => $estimate->sales_tax_address_type, 'items' => $this->when( $estimate->items()->exists(), fn () => EstimateItemResource::collection($estimate->items) ), 'customer' => $this->when( $estimate->customer()->exists(), fn () => new CustomerResource($estimate->customer) ), 'creator' => $this->when( $estimate->creator()->exists(), fn () => new UserResource($estimate->creator) ), 'taxes' => $this->when( $estimate->taxes()->exists(), fn () => TaxResource::collection($estimate->taxes) ), 'fields' => $this->when( $estimate->fields()->exists(), fn () => CustomFieldValueResource::collection($estimate->fields) ), 'company' => $this->when( $estimate->company()->exists(), fn () => new CompanyResource($estimate->company) ), 'currency' => $this->when( $estimate->currency()->exists(), fn () => new CurrencyResource($estimate->currency) ), ]; } }