Add return types, typed parameters, and PHPDoc to all model methods

Modernize all 16 models with missing type declarations:
- Return types on ~87 methods (string, bool, void, array, mixed, etc.)
- Typed parameters where missing
- PHPDoc blocks on non-obvious methods explaining their purpose

Models updated: Invoice, Estimate, Payment, User, Company, Customer,
RecurringInvoice, Setting, CompanySetting, FileDisk, Transaction,
EmailLog, ExchangeRateLog, PaymentMethod, CustomField, CustomFieldValue.
This commit is contained in:
Darko Gjorgjijoski
2026-04-03 20:46:26 +02:00
parent c794f92932
commit 0fa1aac748
16 changed files with 157 additions and 75 deletions

View File

@@ -213,12 +213,12 @@ class Estimate extends Model implements HasMedia
return $query->paginate($limit);
}
public function getPDFData()
public function getPDFData(): mixed
{
return app(EstimateService::class)->getPdfData($this);
}
public function getCompanyAddress()
public function getCompanyAddress(): string|false
{
if ($this->company && (! $this->company->address()->exists())) {
return false;
@@ -229,7 +229,7 @@ class Estimate extends Model implements HasMedia
return $this->getFormattedString($format);
}
public function getCustomerShippingAddress()
public function getCustomerShippingAddress(): string|false
{
if ($this->customer && (! $this->customer->shippingAddress()->exists())) {
return false;
@@ -240,7 +240,7 @@ class Estimate extends Model implements HasMedia
return $this->getFormattedString($format);
}
public function getCustomerBillingAddress()
public function getCustomerBillingAddress(): string|false
{
if ($this->customer && (! $this->customer->billingAddress()->exists())) {
return false;
@@ -251,12 +251,12 @@ class Estimate extends Model implements HasMedia
return $this->getFormattedString($format);
}
public function getNotes()
public function getNotes(): string
{
return PdfHtmlSanitizer::sanitize($this->getFormattedString($this->notes));
}
public function getEmailAttachmentSetting()
public function getEmailAttachmentSetting(): bool
{
$estimateAsAttachment = CompanySetting::getSetting('estimate_email_attachment', $this->company_id);
@@ -267,7 +267,7 @@ class Estimate extends Model implements HasMedia
return true;
}
public function getEmailBody($body)
public function getEmailBody(string $body): string
{
$values = array_merge($this->getFieldsArray(), $this->getExtraFields());
@@ -276,7 +276,7 @@ class Estimate extends Model implements HasMedia
return preg_replace('/{(.*?)}/', '', $body);
}
public function getExtraFields()
public function getExtraFields(): array
{
return [
'{ESTIMATE_DATE}' => $this->formattedEstimateDate,
@@ -286,7 +286,12 @@ class Estimate extends Model implements HasMedia
];
}
public function getInvoiceTemplateName()
/**
* Map the estimate's template name to the corresponding invoice template name.
*
* Falls back to 'invoice1' if the mapped name does not exist in available templates.
*/
public function getInvoiceTemplateName(): string
{
$templateName = Str::replace('estimate', 'invoice', $this->template_name);
@@ -303,7 +308,13 @@ class Estimate extends Model implements HasMedia
return $templateName;
}
public function checkForEstimateConvertAction()
/**
* Handle the post-conversion action for this estimate based on company settings.
*
* Either deletes the estimate or marks it as accepted, depending on the
* 'estimate_convert_action' company setting.
*/
public function checkForEstimateConvertAction(): bool
{
$convertEstimateAction = CompanySetting::getSetting(
'estimate_convert_action',