liyaozhi
2025-10-28 1320688354fd168c51cf2e05f29a2253f4ed9c00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
 
namespace app\common\model\user;
 
use app\common\model\BaseModel;
use app\common\model\settings\Region;
 
class UserAddress extends BaseModel
{
    protected $name = 'user_address';
    protected $pk = 'address_id';
    /**
     * 追加字段
     * @var array
     */
    protected $append = ['region'];
 
    /**
     * 地区名称
     */
    public function getRegionAttr($value, $data)
    {
        return [
            'province' => Region::getNameById($data['province_id']),
            'city' => Region::getNameById($data['city_id']),
            'region' => $data['region_id'] == 0 ? $data['district']
                : Region::getNameById($data['region_id']),
        ];
    }
}