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::getAll())->required(); } /** * 添加奖励组选择 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Select */ public function selectRewardGroup(string $field = 'group_id', string $label = '奖励组'): Field\Select { $options = GameRewardGroup::pluck('name', 'id')->toArray(); return $this->form->select($field, $label)->options($options)->required(); } /** * 添加是否随机发放开关 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Switch */ public function switchIsRandom(string $field = 'is_random', string $label = '随机发放'): Field\Switch { return $this->form->switch($field, $label)->default(0); } /** * 添加随机数量输入 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Number */ public function numberRandomCount(string $field = 'random_count', string $label = '随机数量'): Field\Number { return $this->form->number($field, $label)->default(1)->min(1)->help('随机发放时的奖励数量,仅当随机发放开启时有效'); } /** * 添加是否必中开关 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Switch */ public function switchIsGuaranteed(string $field = 'is_guaranteed', string $label = '必中'): Field\Switch { return $this->form->switch($field, $label)->default(0); } /** * 添加权重输入 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Number */ public function numberWeight(string $field = 'weight', string $label = '权重'): Field\Number { return $this->form->number($field, $label)->default(100)->min(1)->help('权重越高,被选中的概率越大'); } /** * 添加目标ID输入 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Text */ public function textTargetId(string $field = 'target_id', string $label = '目标ID'): Field\Text { return $this->form->text($field, $label)->required()->help('根据奖励类型,填写对应的物品ID、货币ID等'); } /** * 添加参数1输入 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Text */ public function textParam1(string $field = 'param1', string $label = '参数1'): Field\Text { return $this->form->text($field, $label)->default(0)->help('可选参数,根据奖励类型使用'); } /** * 添加参数2输入 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Text */ public function textParam2(string $field = 'param2', string $label = '参数2'): Field\Text { return $this->form->text($field, $label)->default(0)->help('可选参数,根据奖励类型使用'); } /** * 添加数量输入 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Number */ public function numberQuantity(string $field = 'quantity', string $label = '数量'): Field\Number { return $this->form->number($field, $label)->default(1)->min(1)->required(); } /** * 添加奖励项表格 * * @param string $field 字段名 * @param string $label 标签名 * @return Field\Table */ public function tableRewardItems(string $field = 'items', string $label = '奖励项'): Field\Table { return $this->form->table($field, $label, function (Form\NestedForm $table) { $table->select('reward_type', '奖励类型')->options(REWARD_TYPE::getAll())->required(); $table->text('target_id', '目标ID')->required()->help('根据奖励类型,填写对应的物品ID、货币ID等'); $table->text('param1', '参数1')->default(0)->help('可选参数,根据奖励类型使用'); $table->text('param2', '参数2')->default(0)->help('可选参数,根据奖励类型使用'); $table->number('quantity', '数量')->default(1)->min(1)->required(); $table->number('weight', '权重')->default(100)->min(1); $table->switch('is_guaranteed', '必中')->default(0); }); } }