mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
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.
46 lines
917 B
PHP
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);
|
|
}
|
|
}
|