12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace app\admin\model\match;
- use think\Model;
- class Timbre extends Model
- {
-
-
- // 表名
- protected $name = 'match_timbre';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'gender_type_text',
- 'age_type_text'
- ];
-
-
- public function getGenderTypeList()
- {
- return ['1' => __('Gender_type 1'), '0' => __('Gender_type 0')];
- }
- public function getAgeTypeList()
- {
- return ['0' => __('Age_type 0'), '1' => __('Age_type 1'), '2' => __('Age_type 2')];
- }
- public function getGenderTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['gender_type']) ? $data['gender_type'] : '');
- $list = $this->getGenderTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getAgeTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['age_type']) ? $data['age_type'] : '');
- $list = $this->getAgeTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function matchtype()
- {
- return $this->belongsTo('app\admin\model\match\MatchType', 'type_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|