| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 | 
							- <?php
 
- namespace app\admin\model;
 
- use think\Model;
 
- use traits\model\SoftDelete;
 
- class Servicequestion extends Model
 
- {
 
-     use SoftDelete;
 
-     
 
-     // 表名
 
-     protected $table = 'service_question';
 
-     
 
-     // 自动写入时间戳字段
 
-     protected $autoWriteTimestamp = false;
 
-     // 定义时间戳字段名
 
-     protected $createTime = false;
 
-     protected $updateTime = false;
 
-     protected $deleteTime = 'deletetime';
 
-     // 追加属性
 
-     protected $append = [
 
-         'kind_text',
 
-         'status_text',
 
-         'options_jsonstr'
 
-     ];
 
-     public function getOptionsJsonAttr($value)
 
-     {
 
-         if ($value = json_decode($value, true)) {
 
-             $data = [];
 
-             foreach ($value as $key => $row) {
 
-                 $arr['key']         = $key;
 
-                 $arr['value']       = $row;
 
-                 $arr['click_index'] = false;
 
-                 array_push($data, $arr);
 
-             }
 
-             return $data;
 
-         }
 
-         return [];
 
-     }
 
-     public function getOptionsJsonstrAttr($value, $data)
 
-     {
 
-         return $data['options_json'];
 
-     }
 
-     
 
-     protected static function init()
 
-     {
 
-         self::afterInsert(function ($row) {
 
-             $pk = $row->getPk();
 
-             $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
 
-         });
 
-     }
 
-     
 
-     public function getKindList()
 
-     {
 
-         return ['SINGLE' => __('Kind single'), 'MULTI' => __('Kind multi')];
 
-     }
 
-     public function getStatusList()
 
-     {
 
-         return ['1' => __('Status 1'), '0' => __('Status 0')];
 
-     }
 
-     public function getKindTextAttr($value, $data)
 
-     {
 
-         $value = $value ? $value : (isset($data['kind']) ? $data['kind'] : '');
 
-         $list = $this->getKindList();
 
-         return isset($list[$value]) ? $list[$value] : '';
 
-     }
 
-     public function getStatusTextAttr($value, $data)
 
-     {
 
-         $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
 
-         $list = $this->getStatusList();
 
-         return isset($list[$value]) ? $list[$value] : '';
 
-     }
 
-     public function paper()
 
-     {
 
-         return $this->belongsTo('app\admin\model\Servicepaper', 'paper_id', 'id', [], 'LEFT')->setEagerlyType(0);
 
-     }
 
- }
 
 
  |