审查视图

application/api/model/Order.php 762 字节
李忠强 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
<?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');
    }
李忠强 authored
30 31 32 33 34

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