created notification count api and modified get notification api
This commit is contained in:
@@ -229,11 +229,19 @@ class HomeController extends Controller
|
||||
return response()->json(['status' => 200, 'message' => 'All Notifications mark as read']);
|
||||
}
|
||||
|
||||
public function getUserNotificationCountApi(Request $request)
|
||||
{
|
||||
$user = User::find($request->user()->id);
|
||||
$count = $user->unreadNotifications->count();
|
||||
return response()->json(['status'=>200,'count'=>$count]);
|
||||
}
|
||||
|
||||
public function getAllNotificationsApi(Request $request)
|
||||
{
|
||||
$user = User::find($request->user()->id);
|
||||
$user->notifications->markAsRead();
|
||||
$dataArray = array();
|
||||
foreach ($user->unreadNotifications as $data) {
|
||||
foreach ($user->notifications as $data) {
|
||||
$notify['id'] = $data->id;
|
||||
$notify['message'] = $data->data['message'];
|
||||
$notify['time'] = $data->created_at->diffForHumans();
|
||||
|
||||
Reference in New Issue
Block a user