warn('No output file found — nothing to upsert.'); return; } $items = json_decode(file_get_contents($path), true); foreach ($items as $item) { Story::updateOrCreate( ['id' => $item['id']], [ 'user_id' => $item['user_id'], 'username' => $item['username'], 'profile_pic_url' => $item['profile_pic_url'], 'code' => $item['code'], 'is_video' => $item['is_video'], 'taken_at' => $item['taken_at'], 'expiring_at' => $item['expiring_at'], 'image_url' => $item['image_url'], 'video_url' => $item['video_url'], 'accessibility_caption' => $item['accessibility_caption'], 'muted' => $item['muted'], ] ); } $this->info('Upserted ' . count($items) . ' story items.'); } }