form->select($field, $label) ->options(ACTIVITY_STATUS::getAll()) ->default(ACTIVITY_STATUS::NOT_STARTED->value) ->required(); } /** * 添加活动类型选择 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Select */ public function selectActivityType(string $field = 'type', string $label = '活动类型'): Field\Select { return $this->form->select($field, $label) ->options(ACTIVITY_TYPE::getAll()) ->required(); } /** * 添加条件类型选择 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Select */ public function selectConditionType(string $field = 'condition_type', string $label = '条件类型'): Field\Select { return $this->form->select($field, $label) ->options(CONDITION_TYPE::getAll()) ->required(); } /** * 添加参与状态选择 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Select */ public function selectParticipationStatus(string $field = 'completion_status', string $label = '参与状态'): Field\Select { return $this->form->select($field, $label) ->options(PARTICIPATION_STATUS::getAll()) ->default(PARTICIPATION_STATUS::IN_PROGRESS->value) ->required(); } /** * 添加奖励状态选择 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Select */ public function selectRewardStatus(string $field = 'reward_status', string $label = '奖励状态'): Field\Select { return $this->form->select($field, $label) ->options(REWARD_STATUS::getAll()) ->default(REWARD_STATUS::NOT_CLAIMED->value) ->required(); } /** * 添加奖励类型选择 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Select */ public function selectRewardType(string $field = 'reward_type', string $label = '奖励类型'): Field\Select { return $this->form->select($field, $label) ->options(REWARD_TYPE::getAll()) ->required(); } /** * 添加奖励来源类型选择 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Select */ public function selectRewardSourceType(string $field = 'source_type', string $label = '奖励来源'): Field\Select { return $this->form->select($field, $label) ->options(REWARD_SOURCE_TYPE::getValueDescription()) ->default(REWARD_SOURCE_TYPE::ACTIVITY->value) ->required(); } /** * 添加活动时间范围选择 * * @param string $startField 开始时间字段 * @param string $endField 结束时间字段 * @param string $label 标签名 * @return Field\DateRange */ public function dateTimeRangeActivity(string $startField = 'start_time', string $endField = 'end_time', string $label = '活动时间'): Field\DateRange { return $this->form->dateRange($startField, $endField, $label) ->datetime() ->required(); } /** * 添加活动配置JSON编辑器 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Editor */ public function jsonEditorActivityConfig(string $field = 'config', string $label = '活动配置'): Field\Editor { return $this->form->editor($field, $label) ->help('请输入有效的JSON格式配置'); } /** * 添加活动条件JSON编辑器 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Editor */ public function jsonEditorActivityConditions(string $field = 'conditions', string $label = '活动条件'): Field\Editor { return $this->form->editor($field, $label) ->help('请输入有效的JSON格式条件配置'); } /** * 添加活动奖励JSON编辑器 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Editor */ public function jsonEditorActivityRewards(string $field = 'rewards', string $label = '活动奖励'): Field\Editor { return $this->form->editor($field, $label) ->help('请输入有效的JSON格式奖励配置'); } /** * 添加活动条件表格 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Table */ public function tableActivityConditions(string $field = 'conditions', string $label = '活动条件'): Field\Table { return $this->form->table($field, $label, function (Field\Table\InlineTable $table) { $table->select('type', '条件类型') ->options(CONDITION_TYPE::getAll()) ->required(); $table->text('target_id', '目标ID') ->required(); $table->number('target_value', '目标值') ->min(0) ->required(); $table->text('description', '描述'); }); } /** * 添加活动奖励表格 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Table */ public function tableActivityRewards(string $field = 'rewards', string $label = '活动奖励'): Field\Table { return $this->form->table($field, $label, function (Field\Table\InlineTable $table) { $table->select('type', '奖励类型') ->options(REWARD_TYPE::getAll()) ->required(); $table->text('reward_id', '奖励ID') ->required(); $table->number('quantity', '数量') ->min(1) ->default(1) ->required(); $table->text('description', '描述'); }); } /** * 添加奖励组选择 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\SelectTable */ public function selectRewardGroup(string $field = 'reward_group_id', string $label = '奖励组'): Field\SelectTable { $table = RewardGroupLazyRenderable::make(); return $this->form->selectTable($field, $label) ->from($table) ->model($table->getModel(), 'id', 'name'); } /** * 添加活动名称输入 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Text */ public function textActivityName(string $field = 'name', string $label = '活动名称'): Field\Text { return $this->form->text($field, $label) ->required() ->rules('required|max:50'); } /** * 添加活动描述输入 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Textarea */ public function textareaActivityDescription(string $field = 'description', string $label = '活动描述'): Field\Textarea { return $this->form->textarea($field, $label) ->rows(3) ->rules('max:200'); } /** * 添加活动图标上传 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Image */ public function imageActivityIcon(string $field = 'icon', string $label = '活动图标'): Field\Image { return $this->form->image($field, $label) ->autoUpload() ->uniqueName() ->help('建议尺寸: 200x200px'); } /** * 添加活动背景图上传 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Image */ public function imageActivityBackground(string $field = 'background', string $label = '活动背景图'): Field\Image { return $this->form->image($field, $label) ->autoUpload() ->uniqueName() ->help('建议尺寸: 1920x1080px'); } /** * 添加活动排序输入 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Number */ public function numberActivitySort(string $field = 'sort', string $label = '排序'): Field\Number { return $this->form->number($field, $label) ->default(0) ->help('数字越小越靠前'); } /** * 添加活动是否显示开关 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Switch */ public function switchActivityVisible(string $field = 'is_visible', string $label = '是否显示'): Field\Switch { return $this->form->switch($field, $label) ->default(true); } }