AdModel.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Models;
  12. /**
  13. * 广告管理-模型
  14. * @author laravel开发员
  15. * @since 2020/11/11
  16. * Class AdModel
  17. * @package App\Models
  18. */
  19. class AdModel extends BaseModel
  20. {
  21. // 设置数据表
  22. protected $table = 'ad';
  23. /**
  24. * 获取广告信息
  25. * @param int $id
  26. * @return array|string
  27. * @author laravel开发员
  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['cover']) {
  36. $info['cover'] = get_image_url($info['cover']);
  37. }
  38. // 开始时间
  39. if ($info['start_time']) {
  40. $info['start_time'] = datetime($info['start_time']);
  41. }
  42. // 结束时间
  43. if ($info['end_time']) {
  44. $info['end_time'] = datetime($info['end_time']);
  45. }
  46. // 广告位
  47. if ($info['ad_sort_id']) {
  48. $adSortModel = new AdSortModel();
  49. $adSortInfo = $adSortModel->getInfo($info['ad_sort_id']);
  50. if ($adSortInfo) {
  51. $info['ad_sort_name'] = $adSortInfo['description'] . ">>" . $adSortInfo['loc_id'];
  52. }
  53. }
  54. }
  55. return $info;
  56. }
  57. }