PreviousModel.php 866 B

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