Dairy.php 2.0 KB
<?php

namespace app\admin\model\reservoir\run;

use think\Model;


class Dairy extends Model
{

    

    

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

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

    // 追加属性
    protected $append = [
        'weather_text',
        'safe_text',
        'report_text',
        'deal_text'
    ];
    

    
    public function getWeatherList()
    {
        return ['1' => __('Weather 1'), '2' => __('Weather 2')];
    }

    public function getSafeList()
    {
        return ['1' => __('Safe 1'), '2' => __('Safe 2'), '3' => __('Safe 3'), '4' => __('Safe 4')];
    }

    public function getReportList()
    {
        return ['1' => __('Report 1'), '2' => __('Report 2'), '3' => __('Report 3')];
    }

    public function getDealList()
    {
        return ['1' => __('Deal 1'), '2' => __('Deal 2'), '3' => __('Deal 3')];
    }


    public function getWeatherTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['weather']) ? $data['weather'] : '');
        $list = $this->getWeatherList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getSafeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['safe']) ? $data['safe'] : '');
        $list = $this->getSafeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getReportTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['report']) ? $data['report'] : '');
        $list = $this->getReportList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getDealTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['deal']) ? $data['deal'] : '');
        $list = $this->getDealList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}