Files
InvoiceShelf/app/Domains/Sales/Http/Resources/EstimateResource.php
T
Darko Gjorgjijoski 5ef7804e60 refactor: adopt modular domain architecture (#747)
* 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
2026-08-05 17:40:03 +02:00

80 lines
3.4 KiB
PHP

<?php
namespace App\Domains\Sales\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\Taxation\Http\Resources\TaxResource;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class EstimateResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param Request $request
*/
public function toArray($request): array
{
return [
'id' => $this->id,
'estimate_date' => $this->estimate_date,
'expiry_date' => $this->expiry_date,
'estimate_number' => $this->estimate_number,
'status' => $this->status,
'reference_number' => $this->reference_number,
'tax_per_item' => $this->tax_per_item,
'tax_included' => $this->tax_included,
'discount_per_item' => $this->discount_per_item,
'notes' => $this->getNotes(),
'discount' => $this->discount,
'discount_type' => $this->discount_type,
'discount_val' => $this->discount_val,
'sub_total' => $this->sub_total,
'total' => $this->total,
'tax' => $this->tax,
'unique_hash' => $this->unique_hash,
'creator_id' => $this->creator_id,
'template_name' => $this->template_name,
'customer_id' => $this->customer_id,
'exchange_rate' => $this->exchange_rate,
'base_discount_val' => $this->base_discount_val,
'base_sub_total' => $this->base_sub_total,
'base_total' => $this->base_total,
'base_tax' => $this->base_tax,
'sequence_number' => $this->sequence_number,
'currency_id' => $this->currency_id,
'formatted_expiry_date' => $this->formattedExpiryDate,
'formatted_estimate_date' => $this->formattedEstimateDate,
'estimate_pdf_url' => $this->estimatePdfUrl,
'sales_tax_type' => $this->sales_tax_type,
'sales_tax_address_type' => $this->sales_tax_address_type,
'items' => $this->when($this->items()->exists(), function () {
return EstimateItemResource::collection($this->items);
}),
'customer' => $this->when($this->customer()->exists(), function () {
return new CustomerResource($this->customer);
}),
'creator' => $this->when($this->creator()->exists(), function () {
return new UserResource($this->creator);
}),
'taxes' => $this->when($this->taxes()->exists(), function () {
return TaxResource::collection($this->taxes);
}),
'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);
}),
];
}
}