ActivityModel.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 老猫 <thinkcmf@126.com>
  10. // +----------------------------------------------------------------------
  11. namespace api\activity\model;
  12. use think\Model;
  13. use think\model\concern\SoftDelete;
  14. class ActivityModel extends Model
  15. {
  16. use SoftDelete;
  17. protected $type = ['options' => 'array'];
  18. public function review()
  19. {
  20. return $this->hasOne(ActivityReviewModel::class,'activity_id','id');
  21. }
  22. /**
  23. * 状态名
  24. */
  25. static public function statusText($value)
  26. {
  27. $time = time();
  28. if ($value['start_time'] > $time) {
  29. return '未开始';
  30. }
  31. if ($value['start_time'] < $time && $value['end_time'] > $time) {
  32. return '进行中';
  33. }
  34. if ($value['end_time'] < $time) {
  35. return '已结束';
  36. }
  37. }
  38. }