Report.php 1.12 KB
<?php

namespace addons\qingdong\model;

use think\Model;

class Report Extends Model
{

    // 表名
    protected $name = 'qingdong_report';

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

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

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



    public function getStatusList()
    {
        return ['1' => __('待处理'),'2'=>'同意','3'=>'拒绝'];
    }


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




    public function admin()
    {
        return $this->belongsTo('app\admin\model\Admin', 'staff_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function staff() {
        return $this->hasOne(Staff::class, 'id', 'create_id')->field('id,img,name,post,group_ids')->removeOption('soft_delete');
    }


}