<?php

namespace app\admin\model;

use think\Model;


class Userquestionlog extends Model
{

    

    

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

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

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

    
    public function getIsRightList()
    {
        return ['1' => __('Is_right 1'), '0' => __('Is_right 0')];
    }


    public function getIsRightTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_right']) ? $data['is_right'] : '');
        $list = $this->getIsRightList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function user()
    {
        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


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


    public function jigou()
    {
        return $this->belongsTo('Votejigou', 'jigou_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
