123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace app\common\model\base\question;
- /**
- * @title: 问答中心-问题
- * @Description:
- * @Author: goldenrock 112049337@qq.com
- * @Date: 2024-06-12 09:26:12
- * @return {*}
- * @method: POST
- * @LastEditTime: 2024-06-13 10:29:24
- * @LastEditors: goldenrock 112049337@qq.com
- */
- use app\common\model\Common;
- use app\common\model\base\user\User;
- class Question extends Common
- {
- protected $name = 'system_question';
- protected $createTime = 'create_at';
- protected $updateTime = 'update_at';
- protected $deleteTime = 'delete_at';
- protected $append = ['type_txt','status_txt','uid_txt'];
- static public function typeList()
- {
- $list = QuestionType::cache(50)->column('title','id');
- return $list;
- }
- public function getTypeTxtAttr($value,$data)
- {
- $value = $value ? $value : (isset($data['type_id']) ? $data['type_id'] : '');
- $list = self::typeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- static public function statusList()
- {
- return [1=>'待回复',2=>'已回复'];
- }
- public function getStatusTxtAttr($value,$data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = self::statusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getUidTxtAttr($value,$data)
- {
- $value = $value ? $value : (isset($data['uid']) ? $data['uid'] : '');
- $list = User::cache(50)->column('name','user_id');
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function answers()
- {
- return $this->hasMany(QuestionAnswer::class,'question_id','id');
- }
- public function user()
- {
- return $this->belongsTo(User::class,'uid','user_id')->visible(['avatar','name']);
- }
- }
|