This commit is contained in:
meghamalore
2024-06-27 17:00:22 +05:30
12 changed files with 39 additions and 28 deletions

View File

@@ -529,19 +529,21 @@ class ProfileController extends Controller
$id = $request->id;
// dd(Auth::guard('users')->user());
// dd(getAllNotifications());
$userNotifications = User::find(auth()->guard('users')->user()->id);
if ($id) {
Auth::guard('users')->user()->unreadNotifications->where('id', $id)->markAsRead();
$userNotifications->notifications->where('id', $id)->markAsRead();
}
$notifications = Auth::guard('users')->user()->notifications;
// dd($notifications);
// $notifications = Auth::guard('users')->user()->notifications;
// dd($userNotifications->notifications->toArray());
$notificationHTML = '';
$count = 0;
foreach ($notifications as $data) {
$count++;
$read_at = $data->read_at ? 'style="color:#808080"' : 'style="color:black"';
$oddEven = $count % 2 == 1 ? 'odd' : 'even';
// $count = 0;
foreach ($userNotifications->notifications as $data) {
// $count++;
$background_color = $data->read_at ? 'style="background-color:#efecec"' : 'style="background-color:white"';
$read_at = $data->read_at ? 'style="color:#a3a0a0"' : 'style="color:black"';
// $oddEven = $count % 2 == 1 ? 'odd' : 'even';
// $notificationHTML .= "<li class='item list-item ".$oddEven."' style='color:" . $read_at . ";'>
$notificationHTML .= "<li class='item list-item ".$oddEven."' >
$notificationHTML .= "<li class='item list-item ' ".$background_color." >
<a class='read_notification' ".$read_at . "
data-id='" . $data->id . "'>" . $data->data['message'] . "
<p class='mb-0'>
@@ -551,7 +553,7 @@ class ProfileController extends Controller
</li>";
}
if ($notificationHTML) {
return response()->json(['status' => 200, 'data' => $notificationHTML, 'count'=>Auth::guard('users')->user()->unreadNotifications->count()]);
return response()->json(['status' => 200, 'data' => $notificationHTML, 'count'=>$userNotifications->unreadNotifications->count()]);
}
}
}