This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
yoshop/source/application/common/model/sharing/OrderAddress.php

49 lines
1.1 KiB
PHP
Raw Normal View History

2020-04-25 22:20:29 +08:00
<?php
namespace app\common\model\sharing;
use app\common\model\BaseModel;
use app\common\model\Region as RegionModel;
/**
* 订单收货地址模型
* Class OrderAddress
* @package app\common\model
*/
class OrderAddress extends BaseModel
{
protected $name = 'sharing_order_address';
protected $updateTime = false;
/**
* 追加字段
* @var array
*/
protected $append = ['region'];
/**
* 地区名称
* @param $value
* @param $data
* @return array
*/
public function getRegionAttr($value, $data)
{
return [
'province' => RegionModel::getNameById($data['province_id']),
'city' => RegionModel::getNameById($data['city_id']),
'region' => $data['region_id'] == 0 ? '' : RegionModel::getNameById($data['region_id']),
];
}
/**
* 获取完整地址
* @return string
*/
public function getFullAddress()
{
return $this['region']['province'] . $this['region']['city'] . $this['region']['region'] . $this['detail'];
}
}