63 lines
1.1 KiB
PHP
63 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use RuLong\Order\Contracts\Addressbook;
|
|
|
|
class UserAddress extends Model implements Addressbook
|
|
{
|
|
/**
|
|
* 收件人姓名
|
|
* @return string
|
|
*/
|
|
public function getName()
|
|
{
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
/**
|
|
* 收件人电话
|
|
* @return string
|
|
*/
|
|
public function getMobile()
|
|
{
|
|
return $this->mobile;
|
|
|
|
}
|
|
|
|
/**
|
|
* 收件人详细地址
|
|
* @return string
|
|
*/
|
|
public function getAddress()
|
|
{
|
|
if ($this->Area && $this->Area->info) {
|
|
return str_replace(",", "-", $this->Area->info) . '-' . $this->address;
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
/**
|
|
* 收件人详细地址
|
|
* @return string
|
|
*/
|
|
public function getAllAddressAttribute()
|
|
{
|
|
return str_replace(",", "-", $this->Area->info) . '-' . $this->address;
|
|
|
|
}
|
|
|
|
public function Area()
|
|
{
|
|
return $this->belongsTo(Area::class, 'area_sn', 'sn');
|
|
}
|
|
|
|
public function Province()
|
|
{
|
|
return $this->belongsTo(Area::class, 'province_sn', 'sn');
|
|
}
|
|
|
|
}
|