get(); foreach ($artworks as $artwork) { if ($artwork->id > 76200) { $legacyDetailResponse = $this->getArtworkInfoFromApi($artwork->legacy_id); $response = $legacyDetailResponse->object(); if ($response->artwork->episode_id) { $episode = Episode::where('legacy_id', $response->artwork->episode_id)->first(); if ($episode) { $artwork->episode_id = $episode->id; $this->line('Artwork ID ' . $artwork->id . ' is mapped to Episode ID ' . $episode->id); if ($artwork->isDirty()) { $this->line('This is a new mapping.'); $artwork->save(); } } } } } } private function getArtworkInfoFromApi($artwork_legacy_id) { $response = Http::timeout(180) ->get('https://noagendaartgenerator.com/artworkapi/' . $artwork_legacy_id, [ 'p' => '7476', ] ); return $response; } }