| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <?php
- namespace App\Module\Activity\AdminControllers\Helper;
- use App\Module\Activity\Enums\ACTIVITY_STATUS;
- use App\Module\Activity\Enums\ACTIVITY_TYPE;
- use App\Module\Activity\Enums\CONDITION_TYPE;
- use App\Module\Activity\Enums\PARTICIPATION_STATUS;
- use App\Module\Activity\Enums\REWARD_STATUS;
- use App\Module\Game\Enums\REWARD_TYPE;
- use App\Module\Game\Enums\REWARD_SOURCE_TYPE;
- use Dcat\Admin\Show;
- /**
- * 详情页辅助特性
- *
- * 提供活动模块后台控制器的详情页构建功能的具体实现
- */
- trait ShowHelperTrait
- {
- /**
- * 显示活动状态
- *
- * @param string $field 字段名
- * @param string $label 标签名
- * @return Show\Field
- */
- public function fieldActivityStatus(string $field = 'status', string $label = '活动状态'): Show\Field
- {
- return $this->show->field($field, $label)->using(ACTIVITY_STATUS::getAll());
- }
- /**
- * 显示活动类型
- *
- * @param string $field 字段名
- * @param string $label 标签名
- * @return Show\Field
- */
- public function fieldActivityType(string $field = 'type', string $label = '活动类型'): Show\Field
- {
- return $this->show->field($field, $label)->using(ACTIVITY_TYPE::getAll());
- }
- /**
- * 显示条件类型
- *
- * @param string $field 字段名
- * @param string $label 标签名
- * @return Show\Field
- */
- public function fieldConditionType(string $field = 'condition_type', string $label = '条件类型'): Show\Field
- {
- return $this->show->field($field, $label)->using(CONDITION_TYPE::getAll());
- }
- /**
- * 显示参与状态
- *
- * @param string $field 字段名
- * @param string $label 标签名
- * @return Show\Field
- */
- public function fieldParticipationStatus(string $field = 'completion_status', string $label = '参与状态'): Show\Field
- {
- return $this->show->field($field, $label)->using(PARTICIPATION_STATUS::getAll());
- }
- /**
- * 显示奖励状态
- *
- * @param string $field 字段名
- * @param string $label 标签名
- * @return Show\Field
- */
- public function fieldRewardStatus(string $field = 'reward_status', string $label = '奖励状态'): Show\Field
- {
- return $this->show->field($field, $label)->using(REWARD_STATUS::getAll());
- }
- /**
- * 显示奖励类型
- *
- * @param string $field 字段名
- * @param string $label 标签名
- * @return Show\Field
- */
- public function fieldRewardType(string $field = 'reward_type', string $label = '奖励类型'): Show\Field
- {
- return $this->show->field($field, $label)->using(REWARD_TYPE::getAll());
- }
- /**
- * 显示奖励来源类型
- *
- * @param string $field 字段名
- * @param string $label 标签名
- * @return Show\Field
- */
- public function fieldRewardSourceType(string $field = 'source_type', string $label = '奖励来源'): Show\Field
- {
- return $this->show->field($field, $label)->using(REWARD_SOURCE_TYPE::getValueDescription());
- }
- /**
- * 显示活动时间范围
- *
- * @param string $startField 开始时间字段
- * @param string $endField 结束时间字段
- * @param string $label 标签名
- * @return Show\Field
- */
- public function fieldActivityTimeRange(string $startField = 'start_time', string $endField = 'end_time', string $label = '活动时间'): Show\Field
- {
- return $this->show->field($startField, $label)->as(function ($startTime) use ($endField) {
- $endTime = $this->{$endField};
- return date('Y-m-d H:i:s', strtotime($startTime)) . ' 至 ' . date('Y-m-d H:i:s', strtotime($endTime));
- });
- }
- /**
- * 显示活动配置
- *
- * @param string $field 字段名
- * @param string $label 标签名
- * @return Show\Field
- */
- public function fieldActivityConfig(string $field = 'config', string $label = '活动配置'): Show\Field
- {
- return $this->show->field($field, $label)->json();
- }
- /**
- * 显示活动条件
- *
- * @param string $field 字段名
- * @param string $label 标签名
- * @return Show\Field
- */
- public function fieldActivityConditions(string $field = 'conditions', string $label = '活动条件'): Show\Field
- {
- return $this->show->field($field, $label)->json();
- }
- /**
- * 显示活动奖励
- *
- * @param string $field 字段名
- * @param string $label 标签名
- * @return Show\Field
- */
- public function fieldActivityRewards(string $field = 'rewards', string $label = '活动奖励'): Show\Field
- {
- return $this->show->field($field, $label)->json();
- }
- }
|