6
0
Fork 0

抽奖管理 配置奖品的颜色

base
panliang 2026-05-14 15:22:51 +08:00
parent 635c09c771
commit a6b0ad1d28
5 changed files with 10 additions and 3 deletions

View File

@ -197,6 +197,9 @@ class DrawActivityPrizeController extends Controller
} }
})->ajax(admin_route('api.coupons'))->help("仅奖品类型是 ".DrawPrizeType::Coupon->label()." 可用"); })->ajax(admin_route('api.coupons'))->help("仅奖品类型是 ".DrawPrizeType::Coupon->label()." 可用");
$form->color("other.textColor", "字体颜色")->default("#FFFFFF");
$form->color("other.bgColor", "背景色");
$form->saving(function (Form $form) use ($drawActivity) { $form->saving(function (Form $form) use ($drawActivity) {
if (! $form->isCreating()) { if (! $form->isCreating()) {
$form->deleteInput('draw_activity_id'); $form->deleteInput('draw_activity_id');

View File

@ -21,7 +21,7 @@ class DrawActivityController extends Controller
public function show($id, Request $request) public function show($id, Request $request)
{ {
$drawActivity = DrawActivity::with(['prizes' => function ($builder) { $drawActivity = DrawActivity::with(['prizes' => function ($builder) {
$builder->latest('sort'); $builder->orderBy('sort');
}])->onlyPublished()->findOrFail($id); }])->onlyPublished()->findOrFail($id);
$drawTicket = null; $drawTicket = null;

View File

@ -20,6 +20,7 @@ class DrawActivityPrizeResource extends JsonResource
'icon' => $this->icon, 'icon' => $this->icon,
'type' => $this->type, 'type' => $this->type,
'amount' => trim_trailing_zeros($this->amount), 'amount' => trim_trailing_zeros($this->amount),
'other' => $this->other
]; ];
} }
} }

View File

@ -27,6 +27,7 @@ class DrawActivityPrize extends Model
protected $casts = [ protected $casts = [
'type' => DrawPrizeType::class, 'type' => DrawPrizeType::class,
'limited' => 'bool', 'limited' => 'bool',
'other' => 'json'
]; ];
/** /**
@ -44,7 +45,8 @@ class DrawActivityPrize extends Model
'winnings', 'winnings',
'sort', 'sort',
'auto_send', 'auto_send',
'price_type_id' 'price_type_id',
'other'
]; ];
public static function booted() public static function booted()

View File

@ -26,7 +26,8 @@ class CreateDrawActivityPrizesTable extends Migration
$table->unsignedInteger('winnings')->default(0)->comment('中奖数量'); $table->unsignedInteger('winnings')->default(0)->comment('中奖数量');
$table->integer('sort')->default(0)->comment('排序'); $table->integer('sort')->default(0)->comment('排序');
$table->integer('auto_send')->default(0)->comment('奖品是否自动发放'); $table->integer('auto_send')->default(0)->comment('奖品是否自动发放');
$table->unsignedBigInteger('price_type_id')->nullable()->comment('奖品关联记录id(例如: 奖品是优惠券, 保存 coupons.id)'); $table->unsignedBigInteger('price_type_id')->nullable()->comment('奖品关联记录id(例如: 奖品是优惠券, 保存 coupons.id)');
$table->json('other')->nullable()->comment("奖品其它配置项{textColor: 字体颜色, bgColor: 背景色}");
$table->timestamps(); $table->timestamps();
}); });
} }