mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 19:51:09 -04:00
40 lines
780 B
PHP
40 lines
780 B
PHP
<?php
|
|
namespace Crater\Models;
|
|
|
|
use Crater\Models\Company;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Crater\Models\User;
|
|
use Crater\Models\Country;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
class Address extends Model
|
|
{
|
|
use HasFactory;
|
|
const BILLING_TYPE = 'billing';
|
|
const SHIPPING_TYPE = 'shipping';
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
public function getCountryNameAttribute()
|
|
{
|
|
$name = $this->country ? $this->country->name : null;
|
|
|
|
return $name;
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function company()
|
|
{
|
|
return $this->belongsTo(Company::class);
|
|
}
|
|
|
|
public function country()
|
|
{
|
|
return $this->belongsTo(Country::class);
|
|
}
|
|
}
|