审查视图

addons/litestore/model/Litestoreorderaddress.php 756 字节
李忠强 authored
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 31 32
<?php

namespace addons\litestore\model;

use think\Model;
use addons\litestore\model\Area as AddArea;

class Litestoreorderaddress extends Model
{
    // 表名
    protected $name = 'litestore_order_address';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    
    // 追加属性
    protected $append = ['Area'];
    
    public function getAreaAttr($value, $data)
    {
        return [
            'province' => AddArea::getNameById($data['province_id']),
            'city' => AddArea::getNameById($data['city_id']),
            'region' => AddArea::getNameById($data['region_id']),
        ];
    }

}