*/ private const ROWS = [ [ 'code' => 'shanghai-preliminary', 'name' => '上海预赛路演', 'event_date_text' => '2026年9月18日(星期五)', 'address' => '上海市浦东新区张江科学会堂', 'capacity' => 300, 'signup_start' => '2026-08-10 00:00:00', 'signup_end' => '2026-09-10 23:59:59', 'is_final' => false, 'sort' => 1, ], [ 'code' => 'suzhou-preliminary', 'name' => '苏州预赛路演', 'event_date_text' => '2026年10月30日(星期五)', 'address' => '苏州市工业园区苏州国际博览中心', 'capacity' => 260, 'signup_start' => '2026-09-15 00:00:00', 'signup_end' => '2026-10-20 23:59:59', 'is_final' => false, 'sort' => 2, ], [ 'code' => 'shenzhen-preliminary', 'name' => '深圳预赛路演', 'event_date_text' => '2026年12月25日(星期五)', 'address' => '深圳市南山区深圳湾科技生态园', 'capacity' => 200, 'signup_start' => '2026-11-01 00:00:00', 'signup_end' => '2026-12-18 23:59:59', 'is_final' => false, 'sort' => 3, ], [ 'code' => 'suzhou-final', 'name' => '苏州总决赛', 'event_date_text' => '2027年3月19日(星期五)', 'address' => '苏州市工业园区金鸡湖国际会议中心', 'capacity' => 500, 'signup_start' => '2027-02-01 00:00:00', 'signup_end' => '2027-03-10 23:59:59', 'is_final' => true, 'sort' => 4, ], ]; public function run(): void { $envId = (int) env('DEFAULT_TRACKS_COMPETITION_ID', 0); $competitions = $envId > 0 ? Competition::query()->whereKey($envId)->get() : Competition::query()->orderBy('id')->get(); if ($competitions->isEmpty()) { $this->command?->warn('No competition found, skip audience sessions seed.'); return; } foreach ($competitions as $competition) { foreach (self::ROWS as $row) { AudienceSession::query()->updateOrCreate( [ 'competition_id' => $competition->id, 'code' => $row['code'], ], [ 'name' => $row['name'], 'event_date_text' => $row['event_date_text'], 'address' => $row['address'], 'capacity' => $row['capacity'], 'signup_start_at' => Carbon::parse($row['signup_start'], BizDateTime::TIMEZONE), 'signup_end_at' => Carbon::parse($row['signup_end'], BizDateTime::TIMEZONE), 'is_final' => $row['is_final'], 'sort' => $row['sort'], 'enabled' => true, ] ); } $this->command?->info( 'Synced '.count(self::ROWS)." audience sessions for competition #{$competition->id}." ); } } }