<?php

namespace app\admin\model\story;

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

class StoryLangs extends Model
{

    use SoftDelete;

    

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

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

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

    
    public function getLanglistList()
    {
        return ['zh-cn' => __('Langlist zh-cn'), 'en' => __('Langlist en'), 'es' => __('Langlist es')];
    }


    public function getLanglistTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['langlist']) ? $data['langlist'] : '');
        $list = $this->getLanglistList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
