<?php

namespace app\admin\model\school\classes\activity\order;

use think\Model;
use traits\model\SoftDelete;

class OrderLog extends Model
{

    use SoftDelete;

    

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

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

    // 追加属性
    protected $append = [
        'status_text'
    ];
    

    
    public function getStatusList()
    {
        return ['-3' => __('Status -3'), '0' => __('Status 0'), '2' => __('Status 2'), '3' => __('Status 3'), '4' => __('Status 4'),'5' => __('Status 5'), '6' => __('Status 6'), '9' => __('Status 9')];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function activityorder()
    {
        return $this->belongsTo(Order::class, 'classes_activity_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
