Updated Publications Page
This commit is contained in:
@@ -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[] = '<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"><i class="fas fa-eye"></i></a>';
|
||||
} else {
|
||||
$actions[] = 'No Paper';
|
||||
$actions[] = '<span class="text-muted"><i class="fas fa-times-circle"></i></span>';
|
||||
}
|
||||
|
||||
$userRole = auth()->user()->role->name;
|
||||
@@ -177,10 +197,10 @@ class PublicationsController extends Controller
|
||||
$editRoute = route('faculty.Publications.edit', $publication->id);
|
||||
}
|
||||
|
||||
$actions[] = '<a href="' . $editRoute . '" class="btn btn-sm btn-info mx-1">Edit</a>';
|
||||
$actions[] = '<a href="' . $editRoute . '" class="btn btn-sm btn-info mx-1"><i class="fas fa-edit"></i></a>';
|
||||
|
||||
$deleteRoute = route('publications.destroy', $publication->id);
|
||||
$actions[] = '<button type="button" class="btn btn-sm btn-danger delete-btn" data-id="' . $publication->id . '" data-url="' . $deleteRoute . '">Delete</button>';
|
||||
$actions[] = '<button type="button" class="btn btn-sm btn-danger delete-btn" data-id="' . $publication->id . '" data-url="' . $deleteRoute . '"><i class="fas fa-trash"></i></button>';
|
||||
|
||||
return implode(' ', $actions);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user