FourBaogao.php 3.5 KB
<?php

namespace app\admin\model;

use think\Model;


class FourBaogao extends Model
{

    

    

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

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

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

    
    public function getTypeList()
    {
        return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3'), '4' => __('Type 4'), '5' => __('Type 5'), '6' => __('Type 6'), '7' => __('Type 7'), '8' => __('Type 8'), '9' => __('Type 9'), '10' => __('Type 10')];
    }

    public function getSportTypeList()
    {
        return ['1' => __('Sport_type 1'), '2' => __('Sport_type 2')];
    }
    public function getEatTypeList()
    {
        return ['1' => __('Eat_type 1'), '2' => __('Eat_type 2')];
    }
    public function getBodyTypeList()
    {
        return ['1' => __('Body_type 1'), '2' => __('Body_type 2')];
    }
    public function getSeasonTypeList()
    {
        return ['1' => __('Season_type 1'), '2' => __('Season_type 2')];
    }
    public function getWorkTypeList()
    {
        return ['1' => __('Work_type 1'), '2' => __('Work_type 2')];
    }
    public function getFaceTypeList()
    {
        return ['1' => __('Face_type 1'), '2' => __('Face_type 2')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

//    public function getSportTypeTextAttr($value, $data)
//    {
//        $value = $value ? $value : (isset($data['sport_type']) ? $data['sport_type'] : '');
//        $list = $this->getTypeList();
//        return isset($list[$value]) ? $list[$value] : '';
//    }
//    public function getEatTypeTextAttr($value, $data)
//    {
//        $value = $value ? $value : (isset($data['eat_type']) ? $data['eat_type'] : '');
//        $list = $this->getTypeList();
//        return isset($list[$value]) ? $list[$value] : '';
//    }
//    public function getBodyTypeTextAttr($value, $data)
//    {
//        $value = $value ? $value : (isset($data['bdoy_type']) ? $data['bdoy_type'] : '');
//        $list = $this->getTypeList();
//        return isset($list[$value]) ? $list[$value] : '';
//    }
//    public function getSeasonTypeTextAttr($value, $data)
//    {
//        $value = $value ? $value : (isset($data['season_type']) ? $data['season_type'] : '');
//        $list = $this->getTypeList();
//        return isset($list[$value]) ? $list[$value] : '';
//    }
//    public function getWorkTypeTextAttr($value, $data)
//    {
//        $value = $value ? $value : (isset($data['work_type']) ? $data['work_type'] : '');
//        $list = $this->getTypeList();
//        return isset($list[$value]) ? $list[$value] : '';
//    }
//    public function getFaceTypeTextAttr($value, $data)
//    {
//        $value = $value ? $value : (isset($data['face_type']) ? $data['face_type'] : '');
//        $list = $this->getTypeList();
//        return isset($list[$value]) ? $list[$value] : '';
//    }




    public function activitycard()
    {
        return $this->belongsTo('ActivityCard', 'card_ids', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function goods()
    {
        return $this->belongsTo('Goods', 'eat_Goods_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}