'google_scholar_author', 'author_id' => $profileId, 'api_key' => $apiKey, ]); if (!$response->successful()) { \Log::error('Scholar API request failed: ' . $response->status()); return []; } $json = $response->json(); // Support multiple possible structures $articles = $json['articles'] ?? $json['publications'] ?? $json['results'] ?? []; // ✅ Format and return return collect($articles) ->map(function ($a) { return [ 'title' => $a['title'] ?? $a['name'] ?? null, 'authors' => $a['authors'] ?? ($a['author'] ?? null), 'journal' => $a['publication'] ?? $a['journal'] ?? null, 'year' => $a['year'] ?? ($a['publication_year'] ?? null), 'link' => $a['link'] ?? $a['citation_link'] ?? null, ]; }) ->toArray(); } catch (\Throwable $e) { \Log::error('ScholarService API error: ' . $e->getMessage()); return []; } } }