DiverseYouthNightSchool/application/admin/model/school/classes/VisitDistribution.php

61 lines
1.4 KiB
PHP

<?php
namespace app\admin\model\school\classes;
use think\Model;
class VisitDistribution extends Model
{
// 表名
protected $name = 'school_visit_distribution';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'index_text',
'statistics_time_text'
];
public function getIndexList()
{
return ['access_source_session_cnt' => __('Index access_source_session_cnt'), 'access_staytime_info' => __('Index access_staytime_info'), 'access_depth_info' => __('Index access_depth_info')];
}
public function getIndexTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['index']) ? $data['index'] : '');
$list = $this->getIndexList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getStatisticsTimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['statistics_time']) ? $data['statistics_time'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
protected function setStatisticsTimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
}