Order.php 762 字节
<?php


namespace app\api\model;


use think\Model;

class Order extends Model
{
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    protected $name = 'litestore_order';
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $append = [
        'createtime_text'
    ];

    public function getCreatetimeTextAttr($value,$data)
    {
        $value = !empty($data['createtime']) ? date('Y-m-d',$data['createtime']) : '';
        return $value;
    }

    public function goods()
    {
        return $this->hasMany('OrderGoods','order_id','id');
    }

    public function address()
    {
        return $this->belongsTo('OrderAddress','id','order_id',[],'left')->setEagerlyType(0);
    }
}