OrderAddress.php 744 字节
<?php

namespace app\admin\model;

use think\Model;
use app\common\model\Area;

class OrderAddress extends Model
{

    

    

    // 表名
    protected $name = 'order_address';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    /**
     * 追加字段
     * @var array
     */
    protected $append = ['area'];

    /**
     * 地区名称
     */
    public function getAreaAttr($value, $data)
    {
        return Area::getNameById($data['province_id']).','.Area::getNameById($data['city_id']).','.Area::getNameById($data['district_id']);
    }

}