| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace app\admin\model;
- use think\Model;
- use traits\model\SoftDelete;
- class NewQcode extends Model
- {
- protected $connection = 'mongodb';
- protected $table = 'bach';
- protected $deleteTime = 'delete_time';
- use SoftDelete;
- protected $indexes = [];
- protected $autoWriteTimestamp = true;
- protected $type = [
- 'create_time' => 'datetime',
- 'update_time' => 'datetime',
- ];
- public function createIndex()
- {
- $this->connection->command([
- 'createIndexes' => $this->table,
- 'indexes' => [
- [
- 'key' => ['pid' => 1],
- 'name' => 'pid_index'
- ]
- ]
- ]);
- }
- protected static function init()
- {
- //把当前表加入到监听队列
- Redis_sAdd('watch_tables', "bach");
- self::beforeWrite(function ($model) {
- if (!isset($model->delete_time)){
- $model->delete_time="";
- }
- $model->sync_flag=0;
- });
- }
- public function getStatusList()
- {
- // return ['1' => __('待检测'), '2' => __('部分已检测'), '3' => __('检测已完成'), '4' => __('报告待提交'), '5' => __('已取消')];
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- }
|