Updated Google Avatar, Admin Features, All Pages with small changes, Filters in Publications Page
This commit is contained in:
@@ -43,9 +43,21 @@ class GoogleController extends Controller
|
||||
[
|
||||
'name' => $googleUser->getName() ?: $email,
|
||||
'password' => bcrypt(Str::random(16)), // Generate a random password
|
||||
'profile_image' => $googleUser->getAvatar(),
|
||||
]
|
||||
);
|
||||
|
||||
// Update profile image if it changed or wasn't set (for existing users logging in)
|
||||
if (!$user->profile_image) {
|
||||
$user->update(['profile_image' => $googleUser->getAvatar()]);
|
||||
}
|
||||
|
||||
// Sync to FacultyProfile
|
||||
$profile = \App\Models\FacultyProfile::firstOrCreate(['user_id' => $user->id]);
|
||||
if (!$profile->profile_photo_path) {
|
||||
$profile->update(['profile_photo_path' => $googleUser->getAvatar()]);
|
||||
}
|
||||
|
||||
Auth::login($user);
|
||||
|
||||
return redirect()->route('dashboard');
|
||||
|
||||
@@ -77,12 +77,16 @@ class FacultyProfileController extends Controller
|
||||
|
||||
// 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);
|
||||
if ($profile->profile_photo_path && Storage::disk('public')->exists($profile->profile_photo_path)) {
|
||||
Storage::disk('public')->delete($profile->profile_photo_path);
|
||||
}
|
||||
|
||||
$validated['profile_photo_path'] = $request->file('profile_photo')
|
||||
->store('public/profile_photos');
|
||||
$path = $request->file('profile_photo')->store('profile_photos', 'public');
|
||||
$validated['profile_photo_path'] = $path;
|
||||
|
||||
// Update user profile image as well
|
||||
$user->profile_image = $path;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
// Update profile with validated data
|
||||
|
||||
@@ -142,8 +142,8 @@ class PublicationsController extends Controller
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->has('is_peer_reviewed') && !empty($request->is_peer_reviewed)) {
|
||||
$publications->where('is_peer_reviewed', $request->is_peer_reviewed);
|
||||
if ($request->has('category') && !empty($request->category)) {
|
||||
$publications->where('category', $request->category);
|
||||
}
|
||||
|
||||
if ($request->has('dateFrom') && !empty($request->dateFrom)) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Department;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
@@ -22,7 +23,8 @@ class UserController extends Controller
|
||||
public function index()
|
||||
{
|
||||
$departments = Department::all();
|
||||
return view('pages.users.index', compact('departments'));
|
||||
$roles = Role::all();
|
||||
return view('pages.users.index', compact('departments', 'roles'));
|
||||
}
|
||||
|
||||
public function getUsersData(Request $request)
|
||||
@@ -87,7 +89,11 @@ class UserController extends Controller
|
||||
'email' => 'required|email|unique:users',
|
||||
'password' => 'required|string|min:8',
|
||||
'role_id' => 'required|exists:roles,id',
|
||||
'department_id' => 'nullable|exists:departments,id',
|
||||
'department_id' => 'required|exists:departments,id',
|
||||
'mobile_no' => 'nullable|string|max:15',
|
||||
'extension' => 'nullable|string|max:10',
|
||||
'orcid_id' => 'nullable|string|max:19|unique:users',
|
||||
'scopus_id' => 'nullable|string|max:20|unique:users',
|
||||
]);
|
||||
|
||||
$user = User::create([
|
||||
@@ -96,9 +102,13 @@ class UserController extends Controller
|
||||
'password' => bcrypt($request->password),
|
||||
'role_id' => $request->role_id,
|
||||
'department_id' => $request->department_id,
|
||||
'mobile_no' => $request->mobile_no,
|
||||
'extension' => $request->extension,
|
||||
'orcid_id' => $request->orcid_id,
|
||||
'scopus_id' => $request->scopus_id,
|
||||
]);
|
||||
|
||||
return $user;
|
||||
return response()->json($user, 201);
|
||||
}
|
||||
|
||||
public function show(User $user)
|
||||
|
||||
Reference in New Issue
Block a user