m
This commit is contained in:
@@ -61,6 +61,25 @@ class UserController extends Controller
|
||||
return view('user.send', compact('users'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get statistics for a specific recipient.
|
||||
*/
|
||||
public function getRecipientStats(Request $request): JsonResponse
|
||||
{
|
||||
$receiverMsnv = (string) $request->query('receiver');
|
||||
if (empty($receiverMsnv)) {
|
||||
return response()->json(['success' => false, 'message' => 'Receiver is required'], 400);
|
||||
}
|
||||
|
||||
$sender = Auth::user();
|
||||
$sentCount = $this->userService->getSentCardsToUserThisMonth($sender, $receiverMsnv);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'sent_count' => $sentCount,
|
||||
]);
|
||||
}
|
||||
|
||||
public function storeThankcards(SendThankCardRequest $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
@@ -91,10 +110,15 @@ class UserController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$sender = Auth::user();
|
||||
$newRecipientSentCount = $this->userService->getSentCardsToUserThisMonth($sender, (string) $request->input('receiver'));
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => __('messages.thank_card_send_success'),
|
||||
'receiver_email' => $receiverUser ? $receiverUser->mail : '',
|
||||
'new_balance' => (int) $sender->card,
|
||||
'new_recipient_sent_count' => $newRecipientSentCount,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user