12345678910111213141516171819202122232425262728293031323334 |
- <?php
- namespace app\common\model;
- class PreviousModel extends BaseModel
- {
- // 设置表名
- protected $name = 'previous';
- //自动完成
- protected $autoWriteTimestamp = true;
- // 常量
- const STATUS = [1 => '显示', 2 => '隐藏'];
- const MONTH = [1 => '一月', 2 => '二月', 3 => '三月', 4 => '四月', 5 => '五月', 6 => '六月', 7 => '七月', 8 => '八月', 9 => '九月', 10 => '十月', 11 => '十一月', 12 => '十二月'];
- const STATUS_SHOW = 1;
- const STATUS_HIDE = 2;
- public function getStatusTextAttr($value, $data)
- {
- return self::STATUS[$data['status']];
- }
- public function getMonthTextAttr($value, $data)
- {
- return self::MONTH[$data['month']];
- }
- public function previousYear()
- {
- return $this->hasOne(PreviousYearModel::class, 'id', 'year_id');
- }
- }
|