m
This commit is contained in:
@@ -99,6 +99,41 @@ class UserController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
// New page: list of ThankCards received by the current user
|
||||
public function receivedCards(Request $request): View
|
||||
{
|
||||
$selectedMonth = $request->input('month', Carbon::now()->format('Y-m'));
|
||||
$user = Auth::user();
|
||||
$data = $this->userService->getReceivedPageData($user, $selectedMonth);
|
||||
return view('user.received', $data);
|
||||
}
|
||||
|
||||
// New page: list of ThankCards sent by the current user
|
||||
public function sentCards(Request $request): View
|
||||
{
|
||||
$selectedMonth = $request->input('month', Carbon::now()->format('Y-m'));
|
||||
$user = Auth::user();
|
||||
$data = $this->userService->getSentPageData($user, $selectedMonth);
|
||||
return view('user.sent', $data);
|
||||
}
|
||||
|
||||
// New page: ranking (both received and sent) with tabs
|
||||
public function ranking(Request $request): View
|
||||
{
|
||||
$selectedMonth = $request->input('month', Carbon::now()->format('Y-m'));
|
||||
$user = Auth::user();
|
||||
$receivedRanking = $this->userService->getRankingList('received', $selectedMonth, $user);
|
||||
$sentRanking = $this->userService->getRankingList('sent', $selectedMonth, $user);
|
||||
return view('user.ranking', [
|
||||
'selectedMonth' => $selectedMonth,
|
||||
'receivedRankers' => $receivedRanking['rankers'],
|
||||
'receivedCurrentUserRankItem' => $receivedRanking['currentUserRankItem'],
|
||||
'sentRankers' => $sentRanking['rankers'],
|
||||
'sentCurrentUserRankItem' => $sentRanking['currentUserRankItem'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the change password form.
|
||||
*/
|
||||
|
||||
@@ -193,10 +193,10 @@ class UserService implements UserServiceInterface
|
||||
$currentUserRankItem = $userItem;
|
||||
}
|
||||
|
||||
if ($index < 4) {
|
||||
$rankers[] = $userItem;
|
||||
}
|
||||
// Include every ranked user (no hard limit)
|
||||
$rankers[] = $userItem;
|
||||
$rank++;
|
||||
|
||||
}
|
||||
|
||||
if (!$currentUserRankItem) {
|
||||
@@ -214,6 +214,32 @@ class UserService implements UserServiceInterface
|
||||
];
|
||||
}
|
||||
|
||||
// Retrieve paginated list of received ThankCards for a user
|
||||
public function getReceivedPageData(User $user, string $selectedMonth): array
|
||||
{
|
||||
$start = Carbon::parse($selectedMonth)->startOfMonth();
|
||||
$end = Carbon::parse($selectedMonth)->endOfMonth();
|
||||
$cards = Administration::where('msnv', $user->msnv)
|
||||
->whereBetween('date', [$start, $end])
|
||||
->where('received', '>', 0)
|
||||
->orderBy('date', 'desc')
|
||||
->get();
|
||||
return ['cards' => $cards];
|
||||
}
|
||||
|
||||
// Retrieve paginated list of sent ThankCards for a user
|
||||
public function getSentPageData(User $user, string $selectedMonth): array
|
||||
{
|
||||
$start = Carbon::parse($selectedMonth)->startOfMonth();
|
||||
$end = Carbon::parse($selectedMonth)->endOfMonth();
|
||||
$cards = Administration::where('msnv', $user->msnv)
|
||||
->whereBetween('date', [$start, $end])
|
||||
->where('sent', '>', 0)
|
||||
->orderBy('date', 'desc')
|
||||
->get();
|
||||
return ['cards' => $cards];
|
||||
}
|
||||
|
||||
public function updateProfile(User $user, array $data, ?\Illuminate\Http\UploadedFile $avatarFile = null): void
|
||||
{
|
||||
if (isset($data['name'])) {
|
||||
|
||||
Reference in New Issue
Block a user