ActivityModel.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Laravel框架 [ Laravel ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 Laravel研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: wesmiler <12345678@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Models;
  12. /**
  13. * 寺院活动管理-模型
  14. * @author wesmiler
  15. * @since 2020/11/11
  16. * Class ActivityModel
  17. * @package App\Models
  18. */
  19. class ActivityModel extends BaseModel
  20. {
  21. // 设置数据表
  22. protected $table = 'activity';
  23. /**
  24. * 获取记录信息
  25. * @param int $id 记录ID
  26. * @return array|string
  27. * @author wesmiler
  28. * @since 2020/11/11
  29. */
  30. public function getInfo($id)
  31. {
  32. $info = parent::getInfo($id); // TODO: Change the autogenerated stub
  33. if ($info) {
  34. // 图片
  35. if ($info['thumb']) {
  36. $info['thumb'] = get_image_url($info['thumb']);
  37. }
  38. $publishStart = isset($info['publish_start']) && $info['publish_start']? date('m月d日', strtotime($info['publish_start'])) : '';
  39. $publishEnd = isset($info['publish_end']) && $info['publish_end']? date('m月d日', strtotime($info['publish_end'])) : '';
  40. $info['publish_at'] = $publishStart==$publishEnd? $publishStart : ($publishStart && $publishEnd>$publishStart? $publishStart.'-'.$publishEnd : '');
  41. $info['publish_at_text'] = $info['publish_start'] && $info['publish_end']? $info['publish_start'].'至'.$info['publish_end'] : '';
  42. }
  43. return $info;
  44. }
  45. }