Files
chatroom/database/seeders/RingItemsSeeder.php
T
lkddi 29e43507ac 功能:商店完善戒指板块
迁移:
- 2026_03_01_153959:shop_items 增加 intimacy_bonus/charm_bonus 字段

Seeder(RingItemsSeeder):
- 银质戒指 500金  亲密+10 魅力+30
- 黄金戒指 2000金 亲密+30 魅力+80
- 红宝石戒指 8000金 亲密+80 魅力+200
- 钻石戒指 30000金 亲密+200 魅力+500
- 传说神戒 100000金 亲密+500 魅力+1000

ShopService:
- buyItem() 分支加 ring 类型
- buyRing():扣金币 + 写入 active UserPurchase(背包持有)

ShopController::items():
- 返回 intimacy_bonus/charm_bonus
- 统计 ring_counts(各戒指持有数量)

shop-panel.blade.php:
- 新增「💍 求婚戒指」分组(排在最后)
- 图标右上角红色数字徽章(持有时)
- 卡片下方显示亲密度/魅力加成
- 购买按钮与现有逻辑复用
2026-03-01 15:42:25 +08:00

93 lines
2.8 KiB
PHP

<?php
/**
* 文件功能:初始化商店戒指商品数据
*
* 共 5 档戒指,对应不同价格、亲密度加成、魅力加成。
* 可重复运行(updateOrCreate 幂等)。
*/
namespace Database\Seeders;
use App\Models\ShopItem;
use Illuminate\Database\Seeder;
class RingItemsSeeder extends Seeder
{
/**
* 写入 5 档结婚戒指数据。
*/
public function run(): void
{
$rings = [
[
'slug' => 'ring_silver',
'name' => '银质戒指',
'icon' => '💍',
'description' => '朴素银戒,见证两心相许。',
'price' => 500,
'type' => 'ring',
'intimacy_bonus' => 10,
'charm_bonus' => 30,
'sort_order' => 101,
],
[
'slug' => 'ring_gold',
'name' => '黄金戒指',
'icon' => '💛',
'description' => '18K黄金,情比金坚。',
'price' => 2000,
'type' => 'ring',
'intimacy_bonus' => 30,
'charm_bonus' => 80,
'sort_order' => 102,
],
[
'slug' => 'ring_ruby',
'name' => '红宝石戒指',
'icon' => '❤️',
'description' => '鸽血红宝,热烈如初恋。',
'price' => 8000,
'type' => 'ring',
'intimacy_bonus' => 80,
'charm_bonus' => 200,
'sort_order' => 103,
],
[
'slug' => 'ring_diamond',
'name' => '钻石戒指',
'icon' => '💎',
'description' => '一克拉钻石,誓言永恒。',
'price' => 30000,
'type' => 'ring',
'intimacy_bonus' => 200,
'charm_bonus' => 500,
'sort_order' => 104,
],
[
'slug' => 'ring_legendary',
'name' => '传说神戒',
'icon' => '🌟',
'description' => '世间仅此一款,天命之环,天作之合。',
'price' => 100000,
'type' => 'ring',
'intimacy_bonus' => 500,
'charm_bonus' => 1000,
'sort_order' => 105,
],
];
foreach ($rings as $ring) {
ShopItem::updateOrCreate(
['slug' => $ring['slug']],
array_merge($ring, [
'is_active' => true,
'duration_days' => null,
])
);
}
$this->command->info('✅ 5 枚结婚戒指已写入 shop_items。');
}
}