From b2a7d688460048bc619ce447b3cf52a7583ec67a Mon Sep 17 00:00:00 2001 From: jitendra Date: Tue, 15 Mar 2022 11:09:33 +0530 Subject: [PATCH] Issue #5654 fixed --- .../src/Http/Controllers/Admin/NotificationController.php | 8 ++++---- .../src/Repositories/NotificationRepository.php | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/Webkul/Notification/src/Http/Controllers/Admin/NotificationController.php b/packages/Webkul/Notification/src/Http/Controllers/Admin/NotificationController.php index 1b5deea3f..c2749e166 100644 --- a/packages/Webkul/Notification/src/Http/Controllers/Admin/NotificationController.php +++ b/packages/Webkul/Notification/src/Http/Controllers/Admin/NotificationController.php @@ -54,11 +54,11 @@ class NotificationController extends Controller { $params = request()->all(); - if (isset($params) && isset($params['page'])) { + if (isset($params['page'])) { unset($params['page']); } - if (isset($params) && $params != NULL) { + if (count($params)) { $searchResults = $this->notificationRepository->getParamsData($params); } else { $searchResults = $this->notificationRepository->with('order')->latest()->paginate(10); @@ -66,7 +66,7 @@ class NotificationController extends Controller return [ 'search_results' => $searchResults, - 'total_unread' => $this->notificationRepository->where('read', 0)->count() + 'total_unread' => $this->notificationRepository->where('read', 0)->count(), ]; } @@ -80,7 +80,7 @@ class NotificationController extends Controller if ($notification = $this->notificationRepository->where('order_id', $orderId)->first()) { $notification->read = 1; - + $notification->save(); return redirect()->route('admin.sales.orders.view',$orderId); diff --git a/packages/Webkul/Notification/src/Repositories/NotificationRepository.php b/packages/Webkul/Notification/src/Repositories/NotificationRepository.php index d55f386da..fdd1c3b48 100644 --- a/packages/Webkul/Notification/src/Repositories/NotificationRepository.php +++ b/packages/Webkul/Notification/src/Repositories/NotificationRepository.php @@ -24,19 +24,21 @@ class NotificationRepository extends Repository public function getParamsData($params) { if (isset($params['id']) && isset($params['status'])) { - return $params['status'] != 'All' ? $this->model->where(function($qry)use ($params) { + return $params['status'] != 'All' ? $this->model->where(function($qry) use ($params) { $qry->whereHas('order',function ($q) use ($params) { $q->where(['status' => $params['status']]); }); })->where('order_id', $params['id'])->with('order')->paginate(10) : $this->model->where('order_id', $params['id'])->with('order')->paginate(10) ; } else if (isset($params['status'])) { - return $params['status'] != 'All' ? $this->model->where(function($qry)use ($params){ + return $params['status'] != 'All' ? $this->model->where(function($qry) use ($params) { $qry->whereHas('order',function ($q) use ($params) { $q->where(['status' => $params['status']]); }); })->with('order')->paginate(10): $this->model->with('order')->latest()->paginate(10); + } else if(isset($params['read']) && isset($params['limit'])) { + return $this->model->where('read', $params['read'])->limit($params['limit'])->with('order')->latest()->paginate($params['limit']); } else if(isset($params['limit'])) { - return $this->model->limit($params['limit'])->with('order')->latest()->paginate($params['limit']); + return $this->model; } else if(isset($params['id'])) { return $this->model->where('order_id', $params['id'])->with('order')->paginate(10); }