diff --git a/app/Http/Controllers/Admin/APIs/Customer_API/RulesControllerAPI.php b/app/Http/Controllers/Admin/APIs/Customer_API/RulesControllerAPI.php index baa0c67..fa1f244 100644 --- a/app/Http/Controllers/Admin/APIs/Customer_API/RulesControllerAPI.php +++ b/app/Http/Controllers/Admin/APIs/Customer_API/RulesControllerAPI.php @@ -34,7 +34,7 @@ class RulesControllerAPI extends Controller return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409); } } catch (\Exception $e) { - Log::error('FAW get data controller function failed: ' . $e->getMessage()); + Log::error('Voucher rules get data controller function failed: ' . $e->getMessage()); return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); } } diff --git a/app/Http/Controllers/Admin/ManageNotificationsController.php b/app/Http/Controllers/Admin/ManageNotificationsController.php index e0a89d4..cf1a2ad 100644 --- a/app/Http/Controllers/Admin/ManageNotificationsController.php +++ b/app/Http/Controllers/Admin/ManageNotificationsController.php @@ -81,90 +81,79 @@ class ManageNotificationsController extends Controller * Use : To add notification . */ public function store_notificaton_data(Request $request) - { - // dd($request); - try { - $request->validate([ - 'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048', - ]); +{ + try { + $request->validate([ + 'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048', + ]); - DB::beginTransaction(); + DB::beginTransaction(); - if (isset($request->image)) { - $image = $request->image; - $image_db = null; - } else { - $image = null; - $image_db = $request->image; - } - $tnormalImage = saveSingleImageWithoutCrop($image, 'notification_images', $image_db); - $imagePath = ListingImageUrl('notification_images', $tnormalImage); - - - - - $allCustomerOneSignalIds = IamPrincipal::where('is_active', 1) - ->where('notification_status', 1) - ->where('principal_type_xid', 3) - ->where('state_xid', $request->state) - ->pluck('id'); - - $allRestaurantOneSignalIds = IamPrincipal::where('is_active', 1) - ->where('notification_status', 1) - ->where('principal_type_xid', 3) - ->where('state_xid', $request->state) - ->pluck('id'); - - - // Find the remaining user data - $UserData = IamPrincipal::whereIn('id', $allCustomerOneSignalIds)->get(); - $title = $request->title; - $message = $request->description; - $content_type = 'Notification'; - $imageUrl = $imagePath; - - // FOR all customer - if ($request->user_type == 1) { - foreach ($UserData as $customerIdItem) { - if ($customerIdItem->one_signal_player_id) { - onesignalhelper::sendNotificationApi( - $customerIdItem->one_signal_player_id, - $title, - $message, - $content_type, - $imageUrl, - $id = null - ); - } - onesignalhelper::StoreNotificationDetails($customerIdItem->id, $content_type, $title, $imagePath); - } - } elseif ($request->user_type == 2) { - $restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get(); - - foreach ($restaurantData as $restIdItem) { - - if ($restIdItem->one_signal_player_id) { - onesignalhelper::sendNotificationApi( - $restIdItem->one_signal_player_id, - $title, - $message, - $content_type, - $imageUrl, - $id = null - ); - } - onesignalhelper::StoreNotificationDetails($restIdItem->id, $content_type, $title, $imagePath); - } - } - - DB::commit(); - return jsonResponseWithSuccessMessage(__('success.save_data')); - } catch (Exception $e) { - DB::rollBack(); - Log::error("Notification send Failed " . $e->getMessage()); - return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + if (isset($request->image)) { + $image = $request->image; + $image_db = null; + } else { + $image = null; + $image_db = $request->image; } + + $tnormalImage = saveSingleImageWithoutCrop($image, 'notification_images', $image_db); + $imagePath = ListingImageUrl('notification_images', $tnormalImage); + + // Fetch OneSignal IDs based on the selected states and user type + $states = $request->states; + + $userQuery = IamPrincipal::where('is_active', 1) + ->where('notification_status', 1) + ->where('principal_type_xid', 3) + ->whereIn('state_xid', $states); + + + if ($request->user_type == 1) { + $allCustomerOneSignalIds = $userQuery->pluck('id'); + $UserData = IamPrincipal::whereIn('id', $allCustomerOneSignalIds)->get(); + + foreach ($UserData as $customerIdItem) { + if ($customerIdItem->one_signal_player_id) { + onesignalhelper::sendNotificationApi( + $customerIdItem->one_signal_player_id, + $request->title, + $request->description, + 'Dashboard Notification', + $imagePath, + $id = null + ); + } + onesignalhelper::StoreNotificationDetails($customerIdItem->id, 'Notification', $request->title, $imagePath); + } + } elseif ($request->user_type == 2) { + $allRestaurantOneSignalIds = $userQuery->pluck('id'); + $restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get(); + + foreach ($restaurantData as $restIdItem) { + if ($restIdItem->one_signal_player_id) { + onesignalhelper::sendNotificationApi( + $restIdItem->one_signal_player_id, + $request->title, + $request->description, + 'Dashboard Notification', + $imagePath, + $id = null + ); + } + onesignalhelper::StoreNotificationDetails($restIdItem->id, 'Notification', $request->title, $imagePath); + } + } + + DB::commit(); + return jsonResponseWithSuccessMessage(__('success.save_data')); + } catch (Exception $e) { + DB::rollBack(); + Log::error("Notification send Failed " . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); } +} + /** diff --git a/resources/views/Admin/pages/manage_notification/manage_notification.blade.php b/resources/views/Admin/pages/manage_notification/manage_notification.blade.php index a984e0e..c5c5563 100644 --- a/resources/views/Admin/pages/manage_notification/manage_notification.blade.php +++ b/resources/views/Admin/pages/manage_notification/manage_notification.blade.php @@ -8,36 +8,36 @@ -
-
-
-
-
-
-
Manage Notification
-
-
-
+
+
+
+
+
+
+
Manage Notification
+
+
- -
-
-
- - - - - - - - - - - - - - @foreach ($notifications as $notification) + + + +
+
+
Sr No.Notification contentEmailCreated DateRecipientsDate sentStatus
+ + + + + + + + + + + + + @foreach ($notifications as $notification) @@ -86,40 +86,101 @@ @endforeach - -
Sr No.Notification contentEmailCreated DateRecipientsDate sentStatus
{{ $loop->iteration }} {{ $notification->type }}
-
+ +
- @endsection - - - @section('section_script') - - - - - +
+@endsection + + +@section('section_script') + + + @endsection diff --git a/resources/views/Admin/pages/manage_notification/manage_notifications_add.blade.php b/resources/views/Admin/pages/manage_notification/manage_notifications_add.blade.php index 3e73654..8c3bd2a 100644 --- a/resources/views/Admin/pages/manage_notification/manage_notifications_add.blade.php +++ b/resources/views/Admin/pages/manage_notification/manage_notifications_add.blade.php @@ -69,33 +69,39 @@ value="1" id="select-all-ids" />
-
+ +