Files
InvoiceShelf/app/Models/Address.php
Darko Gjorgjijoski e9ee74cd01 Add return types and typed parameters to remaining 10 models
Complete the type modernization across all models. Adds Builder-typed
$query parameters and return types to all scope methods, typed parameters
on accessors, and PHPDoc on scopePaginateData/scopeApplyFilters.

Models updated: Address, EstimateItem, Expense, ExpenseCategory,
InvoiceItem, Item, Note, Tax, TaxType, Unit.

5 models needed no changes (Country, Currency, ImpersonationLog,
Module, UserSetting) as they had no untyped public methods.
2026-04-03 20:53:41 +02:00

46 lines
917 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Address extends Model
{
use HasFactory;
public const BILLING_TYPE = 'billing';
public const SHIPPING_TYPE = 'shipping';
protected $guarded = ['id'];
public function getCountryNameAttribute(): ?string
{
$name = $this->country ? $this->country->name : null;
return $name;
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function customer(): BelongsTo
{
return $this->belongsTo(Customer::class);
}
public function company(): BelongsTo
{
return $this->belongsTo(Company::class);
}
public function country(): BelongsTo
{
return $this->belongsTo(Country::class);
}
}