resource; return [ 'id' => $expense->id, 'expense_date' => $expense->expense_date, 'expense_number' => $expense->expense_number, 'amount' => $expense->amount, 'notes' => $expense->notes, 'customer_id' => $expense->customer_id, 'attachment_receipt_url' => $expense->receipt_url, 'attachment_receipt' => $expense->receipt, 'attachment_receipt_meta' => $expense->receipt_meta, 'company_id' => $expense->company_id, 'expense_category_id' => $expense->expense_category_id, 'creator_id' => $expense->creator_id, 'formatted_expense_date' => $expense->formattedExpenseDate, 'formatted_created_at' => $expense->formattedCreatedAt, 'exchange_rate' => $expense->exchange_rate, 'currency_id' => $expense->currency_id, 'base_amount' => $expense->base_amount, 'payment_method_id' => $expense->payment_method_id, 'taxes' => TaxResource::collection($this->whenLoaded('taxes')), 'customer' => $this->when( $expense->customer()->exists(), fn () => new CustomerResource($expense->customer) ), 'expense_category' => $this->when( $expense->category()->exists(), fn () => new ExpenseCategoryResource($expense->category) ), 'creator' => $this->when( $expense->creator()->exists(), fn () => new UserResource($expense->creator) ), 'fields' => $this->when( $expense->fields()->exists(), fn () => CustomFieldValueResource::collection($expense->fields) ), 'company' => $this->when( $expense->company()->exists(), fn () => new CompanyResource($expense->company) ), 'currency' => $this->when( $expense->currency()->exists(), fn () => new CurrencyResource($expense->currency) ), 'payment_method' => $this->when( $expense->paymentMethod()->exists(), fn () => new PaymentMethodResource($expense->paymentMethod) ), ]; } }