diff --git a/app/Http/Controllers/PublicationsController.php b/app/Http/Controllers/PublicationsController.php index fe03206..74ff25b 100644 --- a/app/Http/Controllers/PublicationsController.php +++ b/app/Http/Controllers/PublicationsController.php @@ -62,6 +62,7 @@ class PublicationsController extends Controller $year = date('Y', strtotime($validated['start_date'])); $username = $publication->user->name; + $userId = $publication->user->id; $originalName = $request->file('paper_file')->getClientOriginalName(); $fileName = $username . '_' . $originalName; @@ -116,7 +117,7 @@ class PublicationsController extends Controller return response()->json(['success' => 'Publication deleted successfully']); } - public function getPublicationsResponses() + public function getPublicationsResponses(Request $request) { $user = auth()->user(); $isAdmin = $user->role->name === 'Admin'; @@ -134,6 +135,25 @@ class PublicationsController extends Controller ->where('faculty_id', $user->id); } + // Apply filters + if ($request->has('department') && !empty($request->department)) { + $publications->whereHas('department', function ($query) use ($request) { + $query->where('id', $request->department); + }); + } + + if ($request->has('is_peer_reviewed') && !empty($request->is_peer_reviewed)) { + $publications->where('is_peer_reviewed', $request->is_peer_reviewed); + } + + if ($request->has('dateFrom') && !empty($request->dateFrom)) { + $publications->where('start_date', '>=', $request->dateFrom); + } + + if ($request->has('dateTo') && !empty($request->dateTo)) { + $publications->where('end_date', '<=', $request->dateTo); + } + return DataTables::of($publications) ->addColumn('user_name', function ($publication) { return $publication->user->name ?? 'Unknown'; @@ -163,9 +183,9 @@ class PublicationsController extends Controller $actions = []; if ($publication->paper_file) { - $actions[] = 'View Paper'; + $actions[] = ''; } else { - $actions[] = 'No Paper'; + $actions[] = ''; } $userRole = auth()->user()->role->name; @@ -177,10 +197,10 @@ class PublicationsController extends Controller $editRoute = route('faculty.Publications.edit', $publication->id); } - $actions[] = 'Edit'; + $actions[] = ''; $deleteRoute = route('publications.destroy', $publication->id); - $actions[] = ''; + $actions[] = ''; return implode(' ', $actions); }) diff --git a/database/migrations/2025_11_21_171210_add_profile_image_to_users_table.php b/database/migrations/2025_11_21_171210_add_profile_image_to_users_table.php new file mode 100644 index 0000000..702954c --- /dev/null +++ b/database/migrations/2025_11_21_171210_add_profile_image_to_users_table.php @@ -0,0 +1,28 @@ +string('profile_image')->nullable()->after('email'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('profile_image'); + }); + } +}; diff --git a/resources/views/pages/publications/index.blade.php b/resources/views/pages/publications/index.blade.php index 8c8e5b6..bf37b1c 100644 --- a/resources/views/pages/publications/index.blade.php +++ b/resources/views/pages/publications/index.blade.php @@ -1,7 +1,7 @@ @extends('layouts.app') @section('content') - +
@@ -11,58 +11,139 @@ All Publications @if(auth()->user()->role->name === 'Faculty') - - - @endif -
-
- - @if(auth()->user()->role->name === 'Faculty') -