26 lines
724 B
PHP
26 lines
724 B
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
use App\Models\Customer;
|
|
use App\Models\Invoice;
|
|
|
|
class InvoiceBuyer
|
|
{
|
|
public static function fromCustomer(?Customer $customer): array
|
|
{
|
|
return [
|
|
'name' => $customer?->fullname ?? '',
|
|
'company' => $customer?->invoice_company ?: ($customer?->company ?? ''),
|
|
'tax_code' => $customer?->tax_code ?? '',
|
|
'address' => $customer?->invoice_address ?: ($customer?->address ?? ''),
|
|
'email' => $customer?->invoice_email ?: ($customer?->email ?? ''),
|
|
];
|
|
}
|
|
|
|
public static function forInvoice(Invoice $invoice): array
|
|
{
|
|
return $invoice->buyer_snapshot ?: self::fromCustomer($invoice->customer);
|
|
}
|
|
}
|