GridHelperTrait.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Module\Promotion\AdminControllers\Helper;
  3. use App\Module\Promotion\Enums\PROFIT_SOURCE_TYPE;
  4. use App\Module\Promotion\Enums\REFERRAL_CHANGE_REASON;
  5. use App\Module\Promotion\Enums\REFERRAL_CODE_STATUS;
  6. use App\Module\Promotion\Enums\REFERRAL_CODE_USAGE_STATUS;
  7. /**
  8. * 列表页辅助特性
  9. *
  10. * 提供列表页的辅助方法,如列的显示、格式化等。
  11. */
  12. trait GridHelperTrait
  13. {
  14. /**
  15. * 显示推荐码状态
  16. *
  17. * @param string $field 字段名
  18. * @param string $label 标签
  19. * @return \Dcat\Admin\Grid\Column
  20. */
  21. public function columnReferralCodeStatus(string $field = 'status', string $label = '状态')
  22. {
  23. return $this->grid->column($field, $label)->using(REFERRAL_CODE_STATUS::getOptions());
  24. }
  25. /**
  26. * 显示推荐码使用状态
  27. *
  28. * @param string $field 字段名
  29. * @param string $label 标签
  30. * @return \Dcat\Admin\Grid\Column
  31. */
  32. public function columnReferralCodeUsageStatus(string $field = 'status', string $label = '状态')
  33. {
  34. return $this->grid->column($field, $label)->using(REFERRAL_CODE_USAGE_STATUS::getOptions());
  35. }
  36. /**
  37. * 显示推荐关系修改原因
  38. *
  39. * @param string $field 字段名
  40. * @param string $label 标签
  41. * @return \Dcat\Admin\Grid\Column
  42. */
  43. public function columnReferralChangeReason(string $field = 'reason', string $label = '修改原因')
  44. {
  45. return $this->grid->column($field, $label)->using(REFERRAL_CHANGE_REASON::getOptions());
  46. }
  47. /**
  48. * 显示收益来源类型
  49. *
  50. * @param string $field 字段名
  51. * @param string $label 标签
  52. * @return \Dcat\Admin\Grid\Column
  53. */
  54. public function columnProfitSourceType(string $field = 'source_type', string $label = '来源类型')
  55. {
  56. return $this->grid->column($field, $label)->using(PROFIT_SOURCE_TYPE::getOptions());
  57. }
  58. }