You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.1 KiB

  1. <?php
  2. declare (strict_types=1);
  3. namespace App\Model;
  4. use Hyperf\DbConnection\Model\Model;
  5. /**
  6. */
  7. class Ad extends Model
  8. {
  9. /**
  10. * 跳转类型及说明
  11. */
  12. const ITEM = [
  13. 1 => 'page',
  14. 2 => 'webview',
  15. 3 => 'applet',
  16. ];
  17. /**
  18. * 类型 1 = 首页banners
  19. */
  20. const TYPE_BANNER = 1;
  21. /**
  22. * 启用状态
  23. */
  24. const STATUS_YES = 1;
  25. const STATUS_NO = 2;
  26. /**
  27. * The table associated with the model.
  28. *
  29. * @var string
  30. */
  31. protected $table = 'ims_cjdc_ad';
  32. /**
  33. * The attributes that are mass assignable.
  34. *
  35. * @var array
  36. */
  37. protected $fillable = [];
  38. /**
  39. * The attributes that should be cast to native types.
  40. *
  41. * @var array
  42. */
  43. protected $casts = [];
  44. protected $appends = [
  45. 'item_text',
  46. 'redirect_url'
  47. ];
  48. /**
  49. * 获取跳转说明
  50. */
  51. public function getItemTextAttribute()
  52. {
  53. return self::ITEM[$this->item];
  54. }
  55. /**
  56. * 获取跳转连接
  57. */
  58. public function getRedirectUrlAttribute()
  59. {
  60. return $this->src ?: $this->src2;
  61. }
  62. }