<?php

namespace app\admin\model\books;

use think\Model;


class BooksFile extends Model
{





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

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

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

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



    public function getTypeList()
    {
        return ['0' => __('课件'), '1' => __('资源'), '2' => __('资料包')];
    }

    public function getIsSpecimenList()
    {
        return ['0' => __('是'), '1' => __('否')];
    }

    public function getIsDeletedList()
    {
        return ['0' => __('是'), '1' => __('否')];
    }


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


    public function getIsSpecimenTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_specimen']) ? $data['is_specimen'] : '');
        $list = $this->getIsSpecimenList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsDeletedTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_deleted']) ? $data['is_deleted'] : '');
        $list = $this->getIsDeletedList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
