get(); $this->info('Fetching cover art for '.$books->count().' books.'); foreach ($books as $book) { $this->info('Fetching cover art for '.$book->book_name); $isbn = str_replace('-', '', $book->isbn); $url = 'https://covers.openlibrary.org/b/isbn/'.$isbn.'-L.jpg'; $response = Http::get($url); if ($response->status() === 200) { $image = getimagesizefromstring($response->body()); if ($image[0] <= 1 || $image[1] <= 1) { $this->error('Failed to fetch cover art.'); continue; } $this->info('Cover art fetched.'); $imagePath = 'cover_images/'.$isbn.'.jpg'; Storage::disk('public')->put($imagePath, $response->body()); $book->cover_image = $imagePath; $book->save(); $this->info('Cover art fetched and saved.'); } else { $this->error('Failed to fetch cover art.'); } } } }