mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-02 05:10:59 +00:00
* refactor: stabilize model identities for domain migration * refactor: extract module platform context * refactor: assign models to domain contexts * refactor: extract ai platform context * refactor: extract storage platform context * refactor: extract mail platform context * refactor: extract pdf platform context * refactor: extract operations platform context * refactor: move installation into operations platform * refactor: extract money domain context * refactor: extract taxation domain context * refactor: extract catalog domain context * refactor: extract metadata domain context * refactor: extract reporting domain context * refactor: extract purchases domain context * refactor: extract receivables domain context * refactor: extract accounts domain context * refactor: complete reporting statement boundary * refactor: extract contacts domain context * refactor: extract sales domain context * refactor: remove legacy application layers * fix: migrate legacy bouncer role identities
68 lines
2.9 KiB
PHP
68 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Purchases\Http\Resources;
|
|
|
|
use App\Domains\Accounts\Http\Resources\CompanyResource;
|
|
use App\Domains\Accounts\Http\Resources\UserResource;
|
|
use App\Domains\Contacts\Http\Resources\CustomerResource;
|
|
use App\Domains\Metadata\Http\Resources\CustomFieldValueResource;
|
|
use App\Domains\Money\Http\Resources\CurrencyResource;
|
|
use App\Domains\Receivables\Http\Resources\PaymentMethodResource;
|
|
use App\Domains\Taxation\Http\Resources\TaxResource;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class ExpenseResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param Request $request
|
|
*/
|
|
public function toArray($request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'expense_date' => $this->expense_date,
|
|
'expense_number' => $this->expense_number,
|
|
'amount' => $this->amount,
|
|
'notes' => $this->notes,
|
|
'customer_id' => $this->customer_id,
|
|
'attachment_receipt_url' => $this->receipt_url,
|
|
'attachment_receipt' => $this->receipt,
|
|
'attachment_receipt_meta' => $this->receipt_meta,
|
|
'company_id' => $this->company_id,
|
|
'expense_category_id' => $this->expense_category_id,
|
|
'creator_id' => $this->creator_id,
|
|
'formatted_expense_date' => $this->formattedExpenseDate,
|
|
'formatted_created_at' => $this->formattedCreatedAt,
|
|
'exchange_rate' => $this->exchange_rate,
|
|
'currency_id' => $this->currency_id,
|
|
'base_amount' => $this->base_amount,
|
|
'payment_method_id' => $this->payment_method_id,
|
|
'taxes' => TaxResource::collection($this->whenLoaded('taxes')),
|
|
'customer' => $this->when($this->customer()->exists(), function () {
|
|
return new CustomerResource($this->customer);
|
|
}),
|
|
'expense_category' => $this->when($this->category()->exists(), function () {
|
|
return new ExpenseCategoryResource($this->category);
|
|
}),
|
|
'creator' => $this->when($this->creator()->exists(), function () {
|
|
return new UserResource($this->creator);
|
|
}),
|
|
'fields' => $this->when($this->fields()->exists(), function () {
|
|
return CustomFieldValueResource::collection($this->fields);
|
|
}),
|
|
'company' => $this->when($this->company()->exists(), function () {
|
|
return new CompanyResource($this->company);
|
|
}),
|
|
'currency' => $this->when($this->currency()->exists(), function () {
|
|
return new CurrencyResource($this->currency);
|
|
}),
|
|
'payment_method' => $this->when($this->paymentMethod()->exists(), function () {
|
|
return new PaymentMethodResource($this->paymentMethod);
|
|
}),
|
|
];
|
|
}
|
|
}
|