Updated Google Scholar Integration,Updated Admin and HOD Dashboard, Added Google Auth: Login Controller and Routes
This commit is contained in:
@@ -201,25 +201,39 @@ class PublicationsController extends Controller
|
||||
|
||||
if (!$user || !$user->scholar_url) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'No Google Scholar URL found for the logged-in user.'
|
||||
'error' => 'No Google Scholar URL found for the logged-in user.'
|
||||
], 400);
|
||||
}
|
||||
|
||||
$scholarService = new \App\Services\ScholarService();
|
||||
$publications = $scholarService->fetchPublications($user->scholar_url);
|
||||
$result = $scholarService->fetchPublications($user->scholar_url);
|
||||
|
||||
// If the service returned an error payload, forward it to UI
|
||||
if (is_array($result) && array_key_exists('error', $result)) {
|
||||
// Log more details if available
|
||||
if (isset($result['body'])) {
|
||||
\Log::error('ScholarService error body', ['body' => $result['body']]);
|
||||
} elseif (isset($result['raw'])) {
|
||||
\Log::warning('ScholarService returned empty articles', ['raw' => $result['raw']]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'error' => $result['error']
|
||||
], 200);
|
||||
}
|
||||
|
||||
// Expecting successful shape ['data' => [...]]
|
||||
$publications = $result['data'] ?? [];
|
||||
|
||||
if (empty($publications)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'No publications found from the provided Scholar profile.'
|
||||
]);
|
||||
'error' => 'No publications found from the provided Scholar profile.'
|
||||
], 200);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'count' => count($publications),
|
||||
'data' => $publications,
|
||||
'count' => count($publications),
|
||||
]);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
Reference in New Issue
Block a user