12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Userstudent extends Model
- {
-
-
- // 表名
- protected $table = 'user_student';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'gender_text',
- 'is_default_text'
- ];
-
-
- public function getGenderList()
- {
- return ['1' => __('Gender 1'), '0' => __('Gender 0')];
- }
- public function getIsDefaultList()
- {
- return ['1' => __('Is_default 1'), '0' => __('Is_default 0')];
- }
- public function getGenderTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['gender']) ? $data['gender'] : '');
- $list = $this->getGenderList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsDefaultTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_default']) ? $data['is_default'] : '');
- $list = $this->getIsDefaultList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function user()
- {
- return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function school()
- {
- return $this->belongsTo('School', 'school_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function grade()
- {
- return $this->belongsTo('Grade', 'grade_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function classes()
- {
- return $this->belongsTo('Classes', 'classes_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|