mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 19:51:09 -04:00
build version 400
This commit is contained in:
39
app/Models/Address.php
Normal file
39
app/Models/Address.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user