feat(profile,publications): integrate working Google Scholar import flow and unified faculty profile system
This commit is contained in:
@@ -64,3 +64,6 @@ AWS_BUCKET=
|
|||||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||||
|
|
||||||
VITE_APP_NAME="${APP_NAME}"
|
VITE_APP_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
SERPAPI_KEY=75d51e578a0d0d2ac4cb1d6ae21410567a105d96b8df36411b4772d91beaa45c
|
||||||
|
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -18,6 +18,6 @@ yarn-error.log
|
|||||||
/auth.json
|
/auth.json
|
||||||
/.fleet
|
/.fleet
|
||||||
/.idea
|
/.idea
|
||||||
/.nova
|
/.novaP
|
||||||
/.vscode
|
/.vscode
|
||||||
/.zed
|
/.zed
|
||||||
|
|||||||
@@ -73,8 +73,14 @@ class FacultyController extends Controller
|
|||||||
|
|
||||||
public function viewPublicationsResponses()
|
public function viewPublicationsResponses()
|
||||||
{
|
{
|
||||||
$departments = Department::all();
|
$user = auth()->user();
|
||||||
return view('pages.publications.index', compact('departments'));
|
|
||||||
|
\Log::info('FacultyController: scholar_url = ' . ($user->scholar_url ?? 'NULL'));
|
||||||
|
|
||||||
|
return view('pages.publications.index', [
|
||||||
|
'scholarUrl' => $user->scholar_url,
|
||||||
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function BooksPublishedForm()
|
public function BooksPublishedForm()
|
||||||
|
|||||||
120
app/Http/Controllers/FacultyProfileController.php
Normal file
120
app/Http/Controllers/FacultyProfileController.php
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\FacultyProfile;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class FacultyProfileController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Show logged-in user's faculty profile.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
$profile = FacultyProfile::firstOrCreate(
|
||||||
|
['user_id' => $user->id],
|
||||||
|
[
|
||||||
|
'name' => $user->name ?? '',
|
||||||
|
'email' => $user->email ?? '',
|
||||||
|
'phone_number' => '',
|
||||||
|
'vidhvan_id' => '',
|
||||||
|
'google_scholar_id' => '',
|
||||||
|
'linkedin_id' => '',
|
||||||
|
'designation' => '',
|
||||||
|
'salutation' => '',
|
||||||
|
'qualification' => '',
|
||||||
|
'address' => '',
|
||||||
|
'employee_id' => '',
|
||||||
|
'department_name' => '',
|
||||||
|
'programme_name' => '',
|
||||||
|
'date_of_joining' => now()->toDateString(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
return view('profile.index', compact('user', 'profile'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the edit form for faculty profile.
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
$profile = FacultyProfile::where('user_id', $user->id)->firstOrFail();
|
||||||
|
|
||||||
|
return view('profile.edit', compact('profile'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update faculty profile.
|
||||||
|
*/
|
||||||
|
public function update(Request $request)
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
$profile = FacultyProfile::where('user_id', $user->id)->firstOrFail();
|
||||||
|
|
||||||
|
$validated = $request->validate([
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'email' => 'required|email',
|
||||||
|
'phone_number' => 'nullable|string|max:20',
|
||||||
|
'employee_id' => 'nullable|string|max:255',
|
||||||
|
'department_name' => 'nullable|string|max:255',
|
||||||
|
'programme_name' => 'nullable|string|max:255',
|
||||||
|
'salutation' => 'nullable|string|max:50',
|
||||||
|
'designation' => 'nullable|string|max:255',
|
||||||
|
'date_of_joining' => 'nullable|date',
|
||||||
|
'qualification' => 'nullable|string|max:500',
|
||||||
|
'address' => 'nullable|string|max:500',
|
||||||
|
'google_scholar_id' => 'nullable|string|max:255',
|
||||||
|
'vidhvan_id' => 'nullable|string|max:255',
|
||||||
|
'linkedin_id' => 'nullable|string|max:255',
|
||||||
|
'profile_photo' => 'nullable|image|max:2048', // 2MB max
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Handle profile photo upload
|
||||||
|
if ($request->hasFile('profile_photo')) {
|
||||||
|
if ($profile->profile_photo_path && Storage::exists($profile->profile_photo_path)) {
|
||||||
|
Storage::delete($profile->profile_photo_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validated['profile_photo_path'] = $request->file('profile_photo')
|
||||||
|
->store('public/profile_photos');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update profile with validated data
|
||||||
|
$profile->update([
|
||||||
|
'name' => $validated['name'] ?? $profile->name,
|
||||||
|
'email' => $validated['email'] ?? $profile->email,
|
||||||
|
'phone_number' => $validated['phone_number'] ?? '',
|
||||||
|
'employee_id' => $validated['employee_id'] ?? '',
|
||||||
|
'department_name' => $validated['department_name'] ?? '',
|
||||||
|
'programme_name' => $validated['programme_name'] ?? '',
|
||||||
|
'salutation' => $validated['salutation'] ?? '',
|
||||||
|
'designation' => $validated['designation'] ?? '',
|
||||||
|
'date_of_joining' => $validated['date_of_joining'] ?? $profile->date_of_joining,
|
||||||
|
'qualification' => $validated['qualification'] ?? '',
|
||||||
|
'address' => $validated['address'] ?? '',
|
||||||
|
'google_scholar_id' => $validated['google_scholar_id'] ?? '',
|
||||||
|
'vidhvan_id' => $validated['vidhvan_id'] ?? '',
|
||||||
|
'linkedin_id' => $validated['linkedin_id'] ?? '',
|
||||||
|
'profile_photo_path' => $validated['profile_photo_path'] ?? $profile->profile_photo_path,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// ✅ Update the main user record (used by PublicationsController)
|
||||||
|
if ($request->filled('google_scholar_id')) {
|
||||||
|
$user->scholar_url = $request->input('google_scholar_id');
|
||||||
|
$user->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✅ Refresh session to ensure it reflects the latest Scholar URL immediately
|
||||||
|
Auth::setUser($user->fresh());
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('faculty.profile.index')
|
||||||
|
->with('success', 'Profile updated successfully.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
|
|
||||||
use App\Http\Requests\ProfileUpdateRequest;
|
|
||||||
use Illuminate\Http\RedirectResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\Redirect;
|
|
||||||
use Illuminate\View\View;
|
|
||||||
|
|
||||||
class ProfileController extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Display the user's profile form.
|
|
||||||
*/
|
|
||||||
public function edit(Request $request): View
|
|
||||||
{
|
|
||||||
return view('profile.edit', [
|
|
||||||
'user' => $request->user(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the user's profile information.
|
|
||||||
*/
|
|
||||||
public function update(ProfileUpdateRequest $request): RedirectResponse
|
|
||||||
{
|
|
||||||
$request->user()->fill($request->validated());
|
|
||||||
|
|
||||||
if ($request->user()->isDirty('email')) {
|
|
||||||
$request->user()->email_verified_at = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$request->user()->save();
|
|
||||||
|
|
||||||
return Redirect::route('profile.edit')->with('status', 'profile-updated');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete the user's account.
|
|
||||||
*/
|
|
||||||
public function destroy(Request $request): RedirectResponse
|
|
||||||
{
|
|
||||||
$request->validateWithBag('userDeletion', [
|
|
||||||
'password' => ['required', 'current_password'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$user = $request->user();
|
|
||||||
|
|
||||||
Auth::logout();
|
|
||||||
|
|
||||||
$user->delete();
|
|
||||||
|
|
||||||
$request->session()->invalidate();
|
|
||||||
$request->session()->regenerateToken();
|
|
||||||
|
|
||||||
return Redirect::to('/');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,9 +6,19 @@ use Illuminate\Http\Request;
|
|||||||
use Yajra\DataTables\Facades\DataTables;
|
use Yajra\DataTables\Facades\DataTables;
|
||||||
use App\Models\Publication;
|
use App\Models\Publication;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use App\Services\ScholarService;
|
||||||
|
|
||||||
class PublicationsController extends Controller
|
class PublicationsController extends Controller
|
||||||
{
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
$scholarUrl = $user->scholar_url;
|
||||||
|
|
||||||
|
return view('pages.publications.index', compact('scholarUrl'));
|
||||||
|
}
|
||||||
|
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
$publication = Publication::findOrFail($id);
|
$publication = Publication::findOrFail($id);
|
||||||
@@ -23,7 +33,6 @@ class PublicationsController extends Controller
|
|||||||
{
|
{
|
||||||
$publication = Publication::findOrFail($id);
|
$publication = Publication::findOrFail($id);
|
||||||
|
|
||||||
// Validate the request data
|
|
||||||
$validated = $request->validate([
|
$validated = $request->validate([
|
||||||
'first_author_name' => 'required|string',
|
'first_author_name' => 'required|string',
|
||||||
'co_authors' => 'nullable|string',
|
'co_authors' => 'nullable|string',
|
||||||
@@ -43,34 +52,27 @@ class PublicationsController extends Controller
|
|||||||
'paper_file' => 'nullable|mimes:jpg,jpeg,png,pdf,doc,docx,zip',
|
'paper_file' => 'nullable|mimes:jpg,jpeg,png,pdf,doc,docx,zip',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Combine start date and time
|
|
||||||
$startDateTime = date('Y-m-d H:i:s', strtotime("{$validated['start_date']} {$validated['start_time']}"));
|
$startDateTime = date('Y-m-d H:i:s', strtotime("{$validated['start_date']} {$validated['start_time']}"));
|
||||||
$endDateTime = date('Y-m-d H:i:s', strtotime("{$validated['end_date']} {$validated['end_time']}"));
|
$endDateTime = date('Y-m-d H:i:s', strtotime("{$validated['end_date']} {$validated['end_time']}"));
|
||||||
|
|
||||||
// Handle the file upload if a new file is provided
|
|
||||||
if ($request->hasFile('paper_file')) {
|
if ($request->hasFile('paper_file')) {
|
||||||
// Delete old file if exists
|
|
||||||
if ($publication->paper_file && Storage::disk('public')->exists($publication->paper_file)) {
|
if ($publication->paper_file && Storage::disk('public')->exists($publication->paper_file)) {
|
||||||
Storage::disk('public')->delete($publication->paper_file);
|
Storage::disk('public')->delete($publication->paper_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract year from start_date
|
|
||||||
$year = date('Y', strtotime($validated['start_date']));
|
$year = date('Y', strtotime($validated['start_date']));
|
||||||
$username = $publication->user->name;
|
$username = $publication->user->name;
|
||||||
|
|
||||||
$originalName = $request->file('paper_file')->getClientOriginalName();
|
$originalName = $request->file('paper_file')->getClientOriginalName();
|
||||||
$fileName = $username . '_' . $originalName;
|
$fileName = $username . '_' . $originalName;
|
||||||
|
|
||||||
// Create path structure: year/faculty_name/Publications
|
|
||||||
$folderPath = 'proofs/' . $year . '/' . $username . '/Publications';
|
$folderPath = 'proofs/' . $year . '/' . $username . '/Publications';
|
||||||
|
|
||||||
// Store file in the specified path
|
|
||||||
$paperFilePath = $request->file('paper_file')->storeAs($folderPath, $fileName, 'public');
|
$paperFilePath = $request->file('paper_file')->storeAs($folderPath, $fileName, 'public');
|
||||||
|
|
||||||
$publication->paper_file = $paperFilePath;
|
$publication->paper_file = $paperFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update other fields
|
|
||||||
$publication->first_author_name = $validated['first_author_name'];
|
$publication->first_author_name = $validated['first_author_name'];
|
||||||
$publication->co_authors = $validated['co_authors'];
|
$publication->co_authors = $validated['co_authors'];
|
||||||
$publication->start_date = $startDateTime;
|
$publication->start_date = $startDateTime;
|
||||||
@@ -96,7 +98,6 @@ class PublicationsController extends Controller
|
|||||||
return redirect()->route('coordinator.PublicationsResponses')
|
return redirect()->route('coordinator.PublicationsResponses')
|
||||||
->with('status', 'Publication updated successfully');
|
->with('status', 'Publication updated successfully');
|
||||||
} else {
|
} else {
|
||||||
// For regular users
|
|
||||||
return redirect()->route('faculty.PublicationsResponses')
|
return redirect()->route('faculty.PublicationsResponses')
|
||||||
->with('status', 'Publication updated successfully');
|
->with('status', 'Publication updated successfully');
|
||||||
}
|
}
|
||||||
@@ -106,7 +107,6 @@ class PublicationsController extends Controller
|
|||||||
{
|
{
|
||||||
$publication = Publication::findOrFail($id);
|
$publication = Publication::findOrFail($id);
|
||||||
|
|
||||||
// Delete the file if it exists
|
|
||||||
if ($publication->paper_file && Storage::disk('public')->exists($publication->paper_file)) {
|
if ($publication->paper_file && Storage::disk('public')->exists($publication->paper_file)) {
|
||||||
Storage::disk('public')->delete($publication->paper_file);
|
Storage::disk('public')->delete($publication->paper_file);
|
||||||
}
|
}
|
||||||
@@ -122,18 +122,14 @@ class PublicationsController extends Controller
|
|||||||
$isAdmin = $user->role->name === 'Admin';
|
$isAdmin = $user->role->name === 'Admin';
|
||||||
$isCoordinator = $user->role->name === 'Coordinator';
|
$isCoordinator = $user->role->name === 'Coordinator';
|
||||||
|
|
||||||
// Query based on role
|
|
||||||
if ($isAdmin) {
|
if ($isAdmin) {
|
||||||
// Admin sees all records
|
|
||||||
$publications = Publication::with('user', 'department');
|
$publications = Publication::with('user', 'department');
|
||||||
} elseif ($isCoordinator) {
|
} elseif ($isCoordinator) {
|
||||||
// Coordinator sees only their department's records
|
|
||||||
$publications = Publication::with('user', 'department')
|
$publications = Publication::with('user', 'department')
|
||||||
->whereHas('user', function ($query) use ($user) {
|
->whereHas('user', function ($query) use ($user) {
|
||||||
$query->where('department_id', $user->department_id);
|
$query->where('department_id', $user->department_id);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Regular users see only their own records
|
|
||||||
$publications = Publication::with('user', 'department')
|
$publications = Publication::with('user', 'department')
|
||||||
->where('faculty_id', $user->id);
|
->where('faculty_id', $user->id);
|
||||||
}
|
}
|
||||||
@@ -166,16 +162,13 @@ class PublicationsController extends Controller
|
|||||||
->addColumn('action', function ($publication) {
|
->addColumn('action', function ($publication) {
|
||||||
$actions = [];
|
$actions = [];
|
||||||
|
|
||||||
// View paper_file button for everyone
|
|
||||||
if ($publication->paper_file) {
|
if ($publication->paper_file) {
|
||||||
$actions[] = '<a href="' . asset('storage/' . $publication->paper_file) . '" target="_blank" class="btn btn-sm btn-primary mr-1">View Paper</a>';
|
$actions[] = '<a href="' . asset('storage/' . $publication->paper_file) . '" target="_blank" class="btn btn-sm btn-primary mr-1">View Paper</a>';
|
||||||
} else {
|
} else {
|
||||||
$actions[] = 'No Paper';
|
$actions[] = 'No Paper';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit button with role-appropriate route
|
|
||||||
$userRole = auth()->user()->role->name;
|
$userRole = auth()->user()->role->name;
|
||||||
// Determine the appropriate route based on user role
|
|
||||||
if ($userRole === 'Admin') {
|
if ($userRole === 'Admin') {
|
||||||
$editRoute = route('admin.Publications.edit', $publication->id);
|
$editRoute = route('admin.Publications.edit', $publication->id);
|
||||||
} elseif ($userRole === 'Coordinator') {
|
} elseif ($userRole === 'Coordinator') {
|
||||||
@@ -194,4 +187,135 @@ class PublicationsController extends Controller
|
|||||||
->rawColumns(['action'])
|
->rawColumns(['action'])
|
||||||
->make(true);
|
->make(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch all publications from user's linked Google Scholar profile.
|
||||||
|
*/
|
||||||
|
public function fetchScholar(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
|
||||||
|
$user = auth()->user();
|
||||||
|
\Log::info('📡 FetchScholar Triggered', ['scholar_url' => $user->scholar_url]);
|
||||||
|
|
||||||
|
|
||||||
|
if (!$user || !$user->scholar_url) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'No Google Scholar URL found for the logged-in user.'
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$scholarService = new \App\Services\ScholarService();
|
||||||
|
$publications = $scholarService->fetchPublications($user->scholar_url);
|
||||||
|
|
||||||
|
if (empty($publications)) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'No publications found from the provided Scholar profile.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'count' => count($publications),
|
||||||
|
'data' => $publications,
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Error fetching publications: '.$e->getMessage(),
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import selected publications (skipping duplicates).
|
||||||
|
*/
|
||||||
|
public function importScholar(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = auth()->user();
|
||||||
|
$facultyId = $user->id;
|
||||||
|
|
||||||
|
$validated = $request->validate([
|
||||||
|
'publications' => 'required|array',
|
||||||
|
'publications.*.title' => 'required|string',
|
||||||
|
'publications.*.authors' => 'nullable|string',
|
||||||
|
'publications.*.journal' => 'nullable|string',
|
||||||
|
'publications.*.year' => 'nullable|string',
|
||||||
|
'publications.*.link' => 'nullable|url',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$rows = $validated['publications'];
|
||||||
|
$imported = 0;
|
||||||
|
$skipped = 0;
|
||||||
|
|
||||||
|
foreach ($rows as $pub) {
|
||||||
|
$exists = \App\Models\Publication::where('faculty_id', $facultyId)
|
||||||
|
->whereRaw('LOWER(title) = ?', [strtolower($pub['title'])])
|
||||||
|
->exists();
|
||||||
|
|
||||||
|
if ($exists) {
|
||||||
|
$skipped++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 🔹 Derive year safely (default to current year if blank)
|
||||||
|
$year = (int)($pub['year'] ?? date('Y'));
|
||||||
|
$year = ($year < 1900 || $year > date('Y') + 1) ? date('Y') : $year;
|
||||||
|
|
||||||
|
// 🔹 Set start/end to that year's first/last day
|
||||||
|
$startDate = "{$year}-01-01";
|
||||||
|
$endDate = "{$year}-12-31";
|
||||||
|
|
||||||
|
// 🔍 Smart Tag Detection
|
||||||
|
$journalLower = strtolower($pub['journal'] ?? '');
|
||||||
|
|
||||||
|
// Detect peer-reviewed journals
|
||||||
|
$isPeerReviewed = (
|
||||||
|
str_contains($journalLower, 'ieee') ||
|
||||||
|
str_contains($journalLower, 'elsevier') ||
|
||||||
|
str_contains($journalLower, 'springer') ||
|
||||||
|
str_contains($journalLower, 'scopus') ||
|
||||||
|
str_contains($journalLower, 'wiley') ||
|
||||||
|
str_contains($journalLower, 'nature') ||
|
||||||
|
str_contains($journalLower, 'taylor & francis')
|
||||||
|
) ? 'yes' : 'no';
|
||||||
|
|
||||||
|
// Detect Scopus / SCI tags
|
||||||
|
$isScopus = str_contains($journalLower, 'scopus') ? 'Yes' : 'No';
|
||||||
|
$isSci = str_contains($journalLower, 'sci') ? 'Yes' : 'No';
|
||||||
|
|
||||||
|
\App\Models\Publication::create([
|
||||||
|
'faculty_id' => $facultyId,
|
||||||
|
'department_id' => $user->department_id,
|
||||||
|
'affiliation' => $pub['journal'] ?? '-',
|
||||||
|
'organizing_institute' => null,
|
||||||
|
'venue_address' => null,
|
||||||
|
'title' => $pub['title'],
|
||||||
|
'first_author_name' => $user->name,
|
||||||
|
'co_authors' => $pub['authors'] ?? '-',
|
||||||
|
'journal_name' => $pub['journal'] ?? '-',
|
||||||
|
'start_date' => $startDate,
|
||||||
|
'end_date' => $endDate,
|
||||||
|
'num_days' => 365,
|
||||||
|
'activity_type' => 'Google Scholar',
|
||||||
|
'is_peer_reviewed' => $isPeerReviewed,
|
||||||
|
'is_scopus_indexed' => $isScopus,
|
||||||
|
'is_sci_indexed' => $isSci,
|
||||||
|
'external_link' => $pub['link'] ?? null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$imported++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => "Imported $imported publications, skipped $skipped duplicates."
|
||||||
|
]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return response()->json(['error' => $e->getMessage()], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
41
app/Models/FacultyProfile.php
Normal file
41
app/Models/FacultyProfile.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class FacultyProfile extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'user_id',
|
||||||
|
'name',
|
||||||
|
'email',
|
||||||
|
'phone_number',
|
||||||
|
'vidhvan_id',
|
||||||
|
'google_scholar_id',
|
||||||
|
'linkedin_id',
|
||||||
|
'designation',
|
||||||
|
'salutation',
|
||||||
|
'qualification',
|
||||||
|
'address',
|
||||||
|
'employee_id',
|
||||||
|
'department_name',
|
||||||
|
'programme_name',
|
||||||
|
'date_of_joining',
|
||||||
|
'profile_photo_path',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'qualification' => 'array',
|
||||||
|
'date_of_joining' => 'date',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Each profile belongs to one user
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,21 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
{
|
{
|
||||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
|
||||||
use HasFactory, Notifiable;
|
use HasFactory, Notifiable;
|
||||||
|
|
||||||
/**
|
|
||||||
* The attributes that are mass assignable.
|
|
||||||
*
|
|
||||||
* @var list<string>
|
|
||||||
*/
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
'email',
|
'email',
|
||||||
@@ -27,24 +20,14 @@ class User extends Authenticatable
|
|||||||
'scopus_id',
|
'scopus_id',
|
||||||
'mobile_no',
|
'mobile_no',
|
||||||
'extension',
|
'extension',
|
||||||
|
'scholar_url', // ✅ added this line
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The attributes that should be hidden for serialization.
|
|
||||||
*
|
|
||||||
* @var list<string>
|
|
||||||
*/
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
'password',
|
'password',
|
||||||
'remember_token',
|
'remember_token',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the attributes that should be cast.
|
|
||||||
*
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
protected function casts(): array
|
protected function casts(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@@ -53,7 +36,6 @@ class User extends Authenticatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function role()
|
public function role()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Role::class);
|
return $this->belongsTo(Role::class);
|
||||||
|
|||||||
67
app/Services/ScholarService.php
Normal file
67
app/Services/ScholarService.php
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
|
class ScholarService
|
||||||
|
{
|
||||||
|
public function fetchPublications(string $url): array
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Extract Google Scholar profile ID (e.g., ssU-uBEAAAAJ)
|
||||||
|
preg_match('/user=([^&]+)/', $url, $match);
|
||||||
|
$profileId = $match[1] ?? null;
|
||||||
|
|
||||||
|
if (!$profileId) {
|
||||||
|
\Log::warning('No Google Scholar ID found in URL: ' . $url);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load API key from .env
|
||||||
|
$apiKey = env('SERPAPI_KEY');
|
||||||
|
|
||||||
|
if (!$apiKey) {
|
||||||
|
\Log::error('SERPAPI_KEY not found in environment variables');
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$endpoint = 'https://serpapi.com/search.json';
|
||||||
|
$response = Http::get($endpoint, [
|
||||||
|
'engine' => '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 [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,7 +34,7 @@ return new class extends Migration
|
|||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
// Add ISSN format check constraint manually
|
// Add ISSN format check constraint manually
|
||||||
DB::statement("ALTER TABLE books_published ADD CONSTRAINT chk_issn_format CHECK (issn REGEXP '^[0-9]{4}-[0-9]{3}[0-9X]$')");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->string('scholar_url')->nullable()->after('scopus_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('scholar_url');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('publications', function (Blueprint $table) {
|
||||||
|
$table->string('organizing_institute')->nullable()->change();
|
||||||
|
$table->string('venue_address')->nullable()->change();
|
||||||
|
$table->string('affiliation')->nullable()->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('publications', function (Blueprint $table) {
|
||||||
|
$table->string('organizing_institute')->nullable(false)->change();
|
||||||
|
$table->string('venue_address')->nullable(false)->change();
|
||||||
|
$table->string('affiliation')->nullable(false)->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
45
database/migrations/create_faculty_profiles_table.php
Normal file
45
database/migrations/create_faculty_profiles_table.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('faculty_profiles', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||||
|
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('email')->unique();
|
||||||
|
$table->string('phone_number')->nullable();
|
||||||
|
$table->string('vidhvan_id');
|
||||||
|
$table->string('google_scholar_id');
|
||||||
|
$table->string('linkedin_id')->nullable();
|
||||||
|
$table->string('designation')->nullable();
|
||||||
|
$table->string('salutation');
|
||||||
|
$table->json('qualification')->nullable(); // multiple quals
|
||||||
|
$table->text('address')->nullable();
|
||||||
|
$table->string('employee_id');
|
||||||
|
$table->string('department_name');
|
||||||
|
$table->string('programme_name');
|
||||||
|
$table->date('date_of_joining');
|
||||||
|
$table->string('profile_photo_path')->nullable();
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('faculty_profiles');
|
||||||
|
}
|
||||||
|
};
|
||||||
14
resources/views/faculty/profile.blade.php
Normal file
14
resources/views/faculty/profile.blade.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container py-5">
|
||||||
|
<h1 class="mb-4">Faculty Profile</h1>
|
||||||
|
|
||||||
|
<div class="card p-4 shadow-sm">
|
||||||
|
<p><strong>Name:</strong> {{ $profile->name }}</p>
|
||||||
|
<p><strong>Email:</strong> {{ $profile->email }}</p>
|
||||||
|
<p><strong>Phone Number:</strong> {{ $profile->phone_number ?: 'N/A' }}</p>
|
||||||
|
<p><strong>Department:</strong> {{ $profile->department_name ?: 'N/A' }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
<link rel="stylesheet" href="{{ asset('assets/frontend/css/app.css') }}">
|
<link rel="stylesheet" href="{{ asset('assets/frontend/css/app.css') }}">
|
||||||
|
<!-- Add Font Awesome for icons -->
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||||
<style>
|
<style>
|
||||||
.navbar-profile-picture {
|
.navbar-profile-picture {
|
||||||
width: 40px;
|
width: 40px;
|
||||||
@@ -12,6 +14,16 @@
|
|||||||
body {
|
body {
|
||||||
padding-top: 70px;
|
padding-top: 70px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Style for dropdown toggle without underline */
|
||||||
|
.dropdown-toggle:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ensure dropdown menu appears above other content */
|
||||||
|
.dropdown-menu {
|
||||||
|
z-index: 1030;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bgGrad text-white fixed-top">
|
<nav class="navbar navbar-expand-lg navbar-dark bgGrad text-white fixed-top">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
@@ -29,9 +41,31 @@
|
|||||||
@if (!Auth::guest())
|
@if (!Auth::guest())
|
||||||
<ul class="navbar-nav me-md-5">
|
<ul class="navbar-nav me-md-5">
|
||||||
<div class="d-flex align-items-center bgRightShade">
|
<div class="d-flex align-items-center bgRightShade">
|
||||||
|
<div class="dropdown ms-2">
|
||||||
|
<a class="d-flex align-items-center text-white text-decoration-none dropdown-toggle"
|
||||||
|
href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
|
<img src="{{ asset('assets/frontend/images/user.png') }}"
|
||||||
|
alt="profile"
|
||||||
|
class="navbar-profile-picture me-2">
|
||||||
|
<span>{{ Auth::user()->name }}</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
<div class="d-none d-md-inline ms-2">
|
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
|
||||||
{{ auth()->user()->name }}
|
<li>
|
||||||
|
<a class="dropdown-item" href="{{ route('faculty.profile.index') }}">
|
||||||
|
<i class="fa-solid fa-id-card me-2 text-primary"></i> Profile
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li><hr class="dropdown-divider"></li>
|
||||||
|
<li>
|
||||||
|
<form method="POST" action="{{ route('logout') }}">
|
||||||
|
@csrf
|
||||||
|
<button type="submit" class="dropdown-item text-danger">
|
||||||
|
<i class="fa-solid fa-right-from-bracket me-2"></i> Logout
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
@extends('layouts.app')
|
@extends('layouts.app')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||||
<div class="container py-4">
|
<div class="container py-4">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
@@ -9,8 +10,54 @@
|
|||||||
<h3 class="page-title m-0">
|
<h3 class="page-title m-0">
|
||||||
<i class="fas fa-book-open me-2 text-primary"></i>All Publications
|
<i class="fas fa-book-open me-2 text-primary"></i>All Publications
|
||||||
</h3>
|
</h3>
|
||||||
|
@if(auth()->user()->role->name === 'Faculty')
|
||||||
|
<input type="hidden" id="scholar-url" value="{{ $scholarUrl ?? '' }}">
|
||||||
|
<button id="btn-fetch-scholar" class="btn btn-outline-primary">
|
||||||
|
<i class="fab fa-google me-1"></i> Import from Google Scholar
|
||||||
|
</button>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
<!-- 🔹 Google Scholar Modal -->
|
||||||
|
@if(auth()->user()->role->name === 'Faculty')
|
||||||
|
<div class="modal fade" id="scholarModal" tabindex="-1" aria-labelledby="scholarModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-xl">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="scholarModalLabel">Select Publications to Import</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div id="scholar-loading" class="text-center my-4 d-none">
|
||||||
|
<div class="spinner-border text-primary"></div>
|
||||||
|
<p class="mt-2">Fetching from Google Scholar...</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="scholar-table-wrapper" class="table-responsive d-none">
|
||||||
|
<table class="table table-bordered align-middle">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><input type="checkbox" id="select-all"></th>
|
||||||
|
<th>Title</th>
|
||||||
|
<th>Authors</th>
|
||||||
|
<th>Journal</th>
|
||||||
|
<th>Year</th>
|
||||||
|
<th>Link</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="scholar-table-body"></tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||||
|
<button id="btn-import-selected" class="btn btn-success" disabled>Import Selected</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
<!-- Table -->
|
<!-- Table -->
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table id="publications-table" class="table table-striped table-hover">
|
<table id="publications-table" class="table table-striped table-hover">
|
||||||
@@ -45,6 +92,9 @@
|
|||||||
|
|
||||||
@section('scripts')
|
@section('scripts')
|
||||||
<script>
|
<script>
|
||||||
|
// 🔹 Global CSRF setup for all fetch() calls
|
||||||
|
window.csrfToken = document.querySelector('meta[name="csrf-token"]').content;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
const sheetName = "Publications";
|
const sheetName = "Publications";
|
||||||
|
|
||||||
@@ -111,5 +161,129 @@
|
|||||||
|
|
||||||
initAjaxRoute(dataRoute);
|
initAjaxRoute(dataRoute);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 🔹 Handle delete button click (for AJAX DataTable)
|
||||||
|
$(document).on('click', '.delete-btn', function () {
|
||||||
|
const button = $(this);
|
||||||
|
const id = button.data('id');
|
||||||
|
const url = button.data('url');
|
||||||
|
|
||||||
|
if (!confirm('Are you sure you want to delete this publication?')) return;
|
||||||
|
|
||||||
|
fetch(url, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-TOKEN': window.csrfToken,
|
||||||
|
'Accept': 'application/json',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => {
|
||||||
|
alert(data.success || 'Deleted successfully');
|
||||||
|
$('#publications-table').DataTable().ajax.reload(null, false);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
alert('Failed to delete publication.');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 🔹 Google Scholar Integration Script (Faculty Only)
|
||||||
|
@if(auth()->user()->role->name === 'Faculty')
|
||||||
|
const fetchBtn = document.getElementById('btn-fetch-scholar');
|
||||||
|
if (fetchBtn) {
|
||||||
|
const modal = new bootstrap.Modal(document.getElementById('scholarModal'));
|
||||||
|
const body = document.getElementById('scholar-table-body');
|
||||||
|
const loading = document.getElementById('scholar-loading');
|
||||||
|
const tableWrap = document.getElementById('scholar-table-wrapper');
|
||||||
|
const importBtn = document.getElementById('btn-import-selected');
|
||||||
|
const scholarUrlInput = document.getElementById('scholar-url');
|
||||||
|
|
||||||
|
fetchBtn.addEventListener('click', () => {
|
||||||
|
const scholarUrl = scholarUrlInput.value.trim();
|
||||||
|
|
||||||
|
if (!scholarUrl) {
|
||||||
|
alert('Please set your Google Scholar profile URL in your profile settings first.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
modal.show();
|
||||||
|
loading.classList.remove('d-none');
|
||||||
|
tableWrap.classList.add('d-none');
|
||||||
|
body.innerHTML = '';
|
||||||
|
|
||||||
|
// ✅ No need to redeclare scholarUrl here again
|
||||||
|
fetch("{{ route('faculty.publications.fetchScholar') }}", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-CSRF-TOKEN": window.csrfToken
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ url: scholarUrl })
|
||||||
|
})
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => {
|
||||||
|
loading.classList.add('d-none');
|
||||||
|
if (data.error) {
|
||||||
|
body.innerHTML = `<tr><td colspan='6' class='text-danger text-center'>${data.error}</td></tr>`;
|
||||||
|
} else {
|
||||||
|
const pubs = data.data;
|
||||||
|
pubs.forEach((p, i) => {
|
||||||
|
body.innerHTML += `
|
||||||
|
<tr>
|
||||||
|
<td><input type="checkbox" class="pub-check" data-index="${i}"></td>
|
||||||
|
<td>${p.title}</td>
|
||||||
|
<td>${p.authors || '-'}</td>
|
||||||
|
<td>${p.journal || '-'}</td>
|
||||||
|
<td>${p.year || '-'}</td>
|
||||||
|
<td><a href="${p.link}" target="_blank">View</a></td>
|
||||||
|
</tr>`;
|
||||||
|
});
|
||||||
|
tableWrap.classList.remove('d-none');
|
||||||
|
importBtn.disabled = false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
loading.classList.add('d-none');
|
||||||
|
body.innerHTML = `<tr><td colspan='6' class='text-danger text-center'>Failed to fetch data.</td></tr>`;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('select-all').addEventListener('change', function() {
|
||||||
|
document.querySelectorAll('.pub-check').forEach(cb => cb.checked = this.checked);
|
||||||
|
});
|
||||||
|
|
||||||
|
importBtn.addEventListener('click', () => {
|
||||||
|
const selected = Array.from(document.querySelectorAll('.pub-check:checked')).map(cb => {
|
||||||
|
const row = cb.closest('tr').children;
|
||||||
|
return {
|
||||||
|
title: row[1].innerText.trim(),
|
||||||
|
authors: row[2].innerText.trim(),
|
||||||
|
journal: row[3].innerText.trim(),
|
||||||
|
year: row[4].innerText.trim(),
|
||||||
|
link: row[5].querySelector('a')?.href || null
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
if (selected.length === 0) return alert("Please select at least one publication.");
|
||||||
|
|
||||||
|
fetch("{{ route('faculty.publications.importScholar') }}", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-CSRF-TOKEN": window.csrfToken
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ publications: selected })
|
||||||
|
})
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => {
|
||||||
|
alert(data.message);
|
||||||
|
modal.hide();
|
||||||
|
location.reload();
|
||||||
|
})
|
||||||
|
.catch(() => alert("Import failed!"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@endif
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
@@ -1,29 +1,105 @@
|
|||||||
<x-app-layout>
|
@extends('layouts.app')
|
||||||
<x-slot name="header">
|
|
||||||
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
|
|
||||||
{{ __('Profile') }}
|
|
||||||
</h2>
|
|
||||||
</x-slot>
|
|
||||||
|
|
||||||
<div class="py-12">
|
@section('content')
|
||||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-6">
|
<div class="container mt-4">
|
||||||
<div class="p-4 sm:p-8 bg-white shadow sm:rounded-lg">
|
<h4 class="mb-4">Edit Faculty Profile</h4>
|
||||||
<div class="max-w-xl">
|
|
||||||
@include('profile.partials.update-profile-information-form')
|
<form action="{{ route('faculty.profile.update') }}" method="POST" enctype="multipart/form-data" class="card shadow-sm p-4">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label class="form-label fw-semibold">Full Name</label>
|
||||||
|
<input type="text" name="name" class="form-control" value="{{ old('name', $profile->name) }}" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label class="form-label fw-semibold">Email</label>
|
||||||
|
<input type="email" name="email" class="form-control" value="{{ old('email', $profile->email) }}" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label class="form-label fw-semibold">Phone Number</label>
|
||||||
|
<input type="text" name="phone_number" class="form-control" value="{{ old('phone_number', $profile->phone_number) }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label class="form-label fw-semibold">Employee ID</label>
|
||||||
|
<input type="text" name="employee_id" class="form-control" value="{{ old('employee_id', $profile->employee_id) }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label class="form-label fw-semibold">Department</label>
|
||||||
|
<input type="text" name="department_name" class="form-control" value="{{ old('department_name', $profile->department_name) }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label class="form-label fw-semibold">Programme</label>
|
||||||
|
<input type="text" name="programme_name" class="form-control" value="{{ old('programme_name', $profile->programme_name) }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4 mb-3">
|
||||||
|
<label class="form-label fw-semibold">Salutation</label>
|
||||||
|
<input type="text" name="salutation" class="form-control" value="{{ old('salutation', $profile->salutation) }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4 mb-3">
|
||||||
|
<label class="form-label fw-semibold">Designation</label>
|
||||||
|
<input type="text" name="designation" class="form-control" value="{{ old('designation', $profile->designation) }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4 mb-3">
|
||||||
|
<label class="form-label fw-semibold">Date of Joining</label>
|
||||||
|
<input type="date" name="date_of_joining" class="form-control" value="{{ old('date_of_joining', $profile->date_of_joining?->format('Y-m-d')) }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label class="form-label fw-semibold">Google Scholar ID</label>
|
||||||
|
<input type="text" class="form-control" id="google_scholar_id" name="google_scholar_id"
|
||||||
|
value="{{ old('google_scholar_id', $profile->google_scholar_id) }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label class="form-label fw-semibold">Vidhwan ID</label>
|
||||||
|
<input type="text" class="form-control" id="vidhwan_id" name="vidhwan_id"
|
||||||
|
value="{{ old('vidhwan_id', $profile->vidhwan_id) }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label class="form-label fw-semibold">LinkedIn Profile</label>
|
||||||
|
<input type="text" class="form-control" id="linkedin_id" name="linkedin_id"
|
||||||
|
value="{{ old('linkedin_id', $profile->linkedin_id) }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-12 mb-3">
|
||||||
|
<label class="form-label fw-semibold">Qualification</label>
|
||||||
|
<textarea name="qualification" class="form-control" rows="2">{{ is_array($profile->qualification) ? implode(', ', $profile->qualification) : $profile->qualification }}</textarea>
|
||||||
|
<small class="text-muted">Separate multiple qualifications with commas (e.g., B.Tech, M.Tech, Ph.D)</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-12 mb-3">
|
||||||
|
<label class="form-label fw-semibold">Address</label>
|
||||||
|
<textarea name="address" class="form-control" rows="2">{{ old('address', $profile->address) }}</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label class="form-label fw-semibold">Profile Photo</label>
|
||||||
|
<input type="file" name="profile_photo" class="form-control">
|
||||||
|
|
||||||
|
@if ($profile->profile_photo_path)
|
||||||
|
<div class="mt-2">
|
||||||
|
<img src="{{ Storage::url($profile->profile_photo_path) }}" alt="Profile Photo" width="100" class="rounded shadow-sm">
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="p-4 sm:p-8 bg-white shadow sm:rounded-lg">
|
<div class="text-end mt-3">
|
||||||
<div class="max-w-xl">
|
<button type="submit" class="btn btn-primary">
|
||||||
@include('profile.partials.update-password-form')
|
<i class="fa fa-save me-1"></i> Save Changes
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</form>
|
||||||
|
</div>
|
||||||
<div class="p-4 sm:p-8 bg-white shadow sm:rounded-lg">
|
@endsection
|
||||||
<div class="max-w-xl">
|
|
||||||
@include('profile.partials.delete-user-form')
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</x-app-layout>
|
|
||||||
|
|||||||
89
resources/views/profile/index.blade.php
Normal file
89
resources/views/profile/index.blade.php
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container mt-4">
|
||||||
|
@if(session('success'))
|
||||||
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||||
|
{{ session('success') }}
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<h4 class="mb-4">Faculty Profile</h4>
|
||||||
|
|
||||||
|
<div class="card shadow-sm p-4">
|
||||||
|
<div class="row align-items-center mb-3">
|
||||||
|
<div class="col-md-2 text-center">
|
||||||
|
@if($profile->profile_photo_path)
|
||||||
|
<img src="{{ Storage::url($profile->profile_photo_path) }}"
|
||||||
|
alt="Profile Photo"
|
||||||
|
class="rounded-circle shadow-sm"
|
||||||
|
width="120" height="120">
|
||||||
|
@else
|
||||||
|
<img src="{{ asset('assets/frontend/images/default-avatar.png') }}"
|
||||||
|
alt="Default Photo"
|
||||||
|
class="rounded-circle shadow-sm"
|
||||||
|
width="120" height="120">
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<h5 class="fw-bold mb-1">{{ $profile->salutation }} {{ $profile->name }}</h5>
|
||||||
|
<p class="mb-0"><strong>{{ $profile->designation }}</strong></p>
|
||||||
|
<p class="text-muted mb-0">{{ $profile->department_name }} — {{ $profile->programme_name }}</p>
|
||||||
|
|
||||||
|
{{-- Compact links row --}}
|
||||||
|
<div class="mt-2 text-md-start text-center">
|
||||||
|
@if($profile->google_scholar_id)
|
||||||
|
<a href="{{ $profile->google_scholar_id }}" target="_blank" rel="noopener noreferrer"
|
||||||
|
class="btn btn-outline-primary btn-sm me-2">
|
||||||
|
<i class="fa fa-graduation-cap me-1"></i> Scholar
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if($profile->vidhwan_id)
|
||||||
|
<a href="https://vidwan.inflibnet.ac.in/profile/{{ $profile->vidhwan_id }}"
|
||||||
|
target="_blank" rel="noopener noreferrer"
|
||||||
|
class="btn btn-outline-secondary btn-sm me-2">
|
||||||
|
<i class="fa fa-id-card me-1"></i> Vidhwan
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if($profile->linkedin_id)
|
||||||
|
<a href="{{ $profile->linkedin_id }}" target="_blank" rel="noopener noreferrer"
|
||||||
|
class="btn btn-outline-info btn-sm">
|
||||||
|
<i class="fa fa-linkedin"></i> LinkedIn
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<p><strong>Email:</strong> {{ $profile->email }}</p>
|
||||||
|
<p><strong>Phone:</strong> {{ $profile->phone_number ?: 'N/A' }}</p>
|
||||||
|
<p><strong>Employee ID:</strong> {{ $profile->employee_id ?: 'N/A' }}</p>
|
||||||
|
<p><strong>Date of Joining:</strong>
|
||||||
|
{{ $profile->date_of_joining ? $profile->date_of_joining->format('d M Y') : 'N/A' }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<p><strong>Qualification:</strong>
|
||||||
|
{{ is_array($profile->qualification) ? implode(', ', $profile->qualification) : ($profile->qualification ?: 'N/A') }}
|
||||||
|
</p>
|
||||||
|
<p><strong>Address:</strong> {{ $profile->address ?: 'N/A' }}</p>
|
||||||
|
<p><strong>Vidhwan ID:</strong> {{ $profile->vidhwan_id ?: 'N/A' }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-end mt-3">
|
||||||
|
<a href="{{ route('faculty.profile.edit') }}" class="btn btn-primary">
|
||||||
|
<i class="fa fa-pen me-1"></i> Edit Profile
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
use App\Http\Controllers\ActivitiesAttendedController;
|
use App\Http\Controllers\ActivitiesAttendedController;
|
||||||
use App\Http\Controllers\ActivitiesOrganisedController;
|
use App\Http\Controllers\ActivitiesOrganisedController;
|
||||||
use App\Http\Controllers\ProfileController;
|
|
||||||
use Illuminate\Support\Facades\Route;
|
|
||||||
use App\Http\Controllers\RoleController;
|
use App\Http\Controllers\RoleController;
|
||||||
use App\Http\Controllers\DepartmentController;
|
use App\Http\Controllers\DepartmentController;
|
||||||
use App\Http\Controllers\UserController;
|
use App\Http\Controllers\UserController;
|
||||||
@@ -18,6 +16,7 @@ use App\Http\Controllers\OnlineCoursesController;
|
|||||||
use App\Http\Controllers\PatentsController;
|
use App\Http\Controllers\PatentsController;
|
||||||
use App\Http\Controllers\PublicationsController;
|
use App\Http\Controllers\PublicationsController;
|
||||||
use App\Http\Middleware\CheckRole;
|
use App\Http\Middleware\CheckRole;
|
||||||
|
use App\Http\Controllers\FacultyProfileController;
|
||||||
|
|
||||||
Route::get('/', function () {
|
Route::get('/', function () {
|
||||||
return redirect('/login');
|
return redirect('/login');
|
||||||
@@ -39,12 +38,6 @@ Route::get('/dashboard', function () {
|
|||||||
})->middleware(['auth', 'verified'])->name('dashboard');
|
})->middleware(['auth', 'verified'])->name('dashboard');
|
||||||
|
|
||||||
|
|
||||||
Route::middleware('auth')->group(function () {
|
|
||||||
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
|
|
||||||
Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
|
|
||||||
Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Activities Attended common routes
|
// Activities Attended common routes
|
||||||
Route::delete('/activities-attended/{id}', [ActivitiesAttendedController::class, 'destroy'])->name('activitiesAttended.destroy');
|
Route::delete('/activities-attended/{id}', [ActivitiesAttendedController::class, 'destroy'])->name('activitiesAttended.destroy');
|
||||||
|
|
||||||
@@ -199,6 +192,11 @@ Route::middleware(['auth', CheckRole::class . ':Coordinator'])->group(function (
|
|||||||
Route::middleware(['auth', CheckRole::class . ':Faculty'])->group(function () {
|
Route::middleware(['auth', CheckRole::class . ':Faculty'])->group(function () {
|
||||||
Route::get('/faculty', [FacultyController::class, 'index'])->name('faculty.dashboard');
|
Route::get('/faculty', [FacultyController::class, 'index'])->name('faculty.dashboard');
|
||||||
|
|
||||||
|
// Faculty Profile Routes - KEPT AS REQUESTED
|
||||||
|
Route::get('/faculty/profile', [FacultyProfileController::class, 'index'])->name('faculty.profile.index');
|
||||||
|
Route::get('/faculty/profile/edit', [FacultyProfileController::class, 'edit'])->name('faculty.profile.edit');
|
||||||
|
Route::put('/faculty/profile', [FacultyProfileController::class, 'update'])->name('faculty.profile.update');
|
||||||
|
|
||||||
// Activities Attended Routes
|
// Activities Attended Routes
|
||||||
Route::get('/faculty/ActivitiesAttendedForm', [FacultyController::class, 'ActivitiesAttendedForm'])->name('faculty.ActivitiesAttendedForm');
|
Route::get('/faculty/ActivitiesAttendedForm', [FacultyController::class, 'ActivitiesAttendedForm'])->name('faculty.ActivitiesAttendedForm');
|
||||||
Route::post('/faculty/ActivitiesAttendedFormResponse', [FacultyController::class, 'ActivitiesAttendedFormResponse'])->name('faculty.ActivitiesAttendedFormResponse');
|
Route::post('/faculty/ActivitiesAttendedFormResponse', [FacultyController::class, 'ActivitiesAttendedFormResponse'])->name('faculty.ActivitiesAttendedFormResponse');
|
||||||
@@ -262,6 +260,16 @@ Route::middleware(['auth', CheckRole::class . ':Faculty'])->group(function () {
|
|||||||
Route::get('/faculty/PatentsResponses/data', [PatentsController::class, 'getPatentsResponses'])->name('faculty.PatentsResponses.data');
|
Route::get('/faculty/PatentsResponses/data', [PatentsController::class, 'getPatentsResponses'])->name('faculty.PatentsResponses.data');
|
||||||
Route::get('/faculty/Patents/{id}/edit', [PatentsController::class, 'edit'])->name('faculty.Patents.edit');
|
Route::get('/faculty/Patents/{id}/edit', [PatentsController::class, 'edit'])->name('faculty.Patents.edit');
|
||||||
Route::put('/faculty/Patents/{id}', [PatentsController::class, 'update'])->name('faculty.Patents.update');
|
Route::put('/faculty/Patents/{id}', [PatentsController::class, 'update'])->name('faculty.Patents.update');
|
||||||
|
|
||||||
|
// Google Scholar import routes (FIXED: changed fetchFromScholar to fetchScholar)
|
||||||
|
Route::post('/faculty/publications/fetch-scholar', [PublicationsController::class, 'fetchScholar'])
|
||||||
|
->name('faculty.publications.fetchScholar');
|
||||||
|
|
||||||
|
Route::post('/faculty/publications/import-scholar', [PublicationsController::class, 'importScholar'])
|
||||||
|
->name('faculty.publications.importScholar');
|
||||||
|
|
||||||
|
Route::post('/faculty/publications/import-selected', [PublicationsController::class, 'importSelected'])
|
||||||
|
->name('faculty.publications.importSelected');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::post('/missing-proofs/check', [MissingProofsController::class, 'checkAndSendEmails'])->name('missing-proofs.check');
|
Route::post('/missing-proofs/check', [MissingProofsController::class, 'checkAndSendEmails'])->name('missing-proofs.check');
|
||||||
@@ -296,3 +304,8 @@ Route::post('/admin/download-proofs', [AdminController::class, 'downloadProofs']
|
|||||||
// Google Login Route
|
// Google Login Route
|
||||||
Route::get('/auth/google', [App\Http\Controllers\Auth\GoogleController::class, 'redirectToGoogle'])->name('google.login');
|
Route::get('/auth/google', [App\Http\Controllers\Auth\GoogleController::class, 'redirectToGoogle'])->name('google.login');
|
||||||
Route::get('/auth/google/callback', [App\Http\Controllers\Auth\GoogleController::class, 'handleGoogleCallback'])->name('google.callback');
|
Route::get('/auth/google/callback', [App\Http\Controllers\Auth\GoogleController::class, 'handleGoogleCallback'])->name('google.callback');
|
||||||
|
|
||||||
|
// ✅ Fallback route alias to avoid 'profile.edit' missing error
|
||||||
|
Route::get('/profile', function () {
|
||||||
|
return redirect()->route('faculty.profile.edit');
|
||||||
|
})->name('profile.edit');
|
||||||
|
|||||||
Reference in New Issue
Block a user