From 8ec08aab03bf44f277782267bbc77ccb03fa6510 Mon Sep 17 00:00:00 2001 From: Hritikkk9 Date: Wed, 3 Jul 2024 16:40:04 +0530 Subject: [PATCH 01/10] webhhhookk kernalss --- app/Http/Middleware/VerifyCsrfToken.php | 4 +++- routes/web.php | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index 98c2c13..3736564 100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -13,6 +13,8 @@ class VerifyCsrfToken extends Middleware */ protected $except = [ 'stripe/webhook', - 'stripe-webhooks' + 'stripe-webhooks', + '/stripe/webhook', + '/stripe-webhooks' ]; } diff --git a/routes/web.php b/routes/web.php index 1537e11..8983443 100644 --- a/routes/web.php +++ b/routes/web.php @@ -31,8 +31,8 @@ use App\Http\Controllers\Admin\ManageRulesController; //webhook -// Route::post('/stripe-webhook', [StripeWebhookController::class, 'handleWebhook']); -// Route::post('/stripe/webhook', [StripeWebhookController::class, 'handleWebhook']); +Route::post('/stripe-webhook', [StripeWebhookController::class, 'handleWebhook']); +Route::post('/stripe/webhook', [StripeWebhookController::class, 'handleWebhook']); // Route::post('/stripe-webhooks', [StripeWebhookController::class, 'getWebhook']); Route::middleware('webhook')->group(function () { From 6f6e1ead22a88b222faacfab1df5ec04ce7b3a98 Mon Sep 17 00:00:00 2001 From: Hritikkk9 Date: Wed, 3 Jul 2024 16:44:29 +0530 Subject: [PATCH 02/10] webhhhookk kernalssj --- routes/web.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/routes/web.php b/routes/web.php index b01900c..8594391 100644 --- a/routes/web.php +++ b/routes/web.php @@ -35,10 +35,10 @@ Route::post('/stripe-webhook', [StripeWebhookController::class, 'handleWebhook'] Route::post('/stripe/webhook', [StripeWebhookController::class, 'handleWebhook']); // Route::post('/stripe-webhooks', [StripeWebhookController::class, 'getWebhook']); -Route::middleware('webhook')->group(function () { - Route::post('/stripe/webhook', [StripeWebhookController::class, 'handleWebhook']); - Route::post('/stripe-webhooks', [StripeWebhookController::class, 'getWebhook']); -}); +// Route::middleware('webhook')->group(function () { +// Route::post('/stripe/webhook', [StripeWebhookController::class, 'handleWebhook']); +// Route::post('/stripe-webhooks', [StripeWebhookController::class, 'getWebhook']); +// }); //stripe webhook end From 08e6eaf26568601115a7ed6a129ad9e302f1f2a2 Mon Sep 17 00:00:00 2001 From: sayliraut Date: Wed, 3 Jul 2024 16:58:35 +0530 Subject: [PATCH 03/10] changes --- .../Admin/ManageNotificationsController.php | 146 ++++++++++-------- .../manage_notifications_add.blade.php | 71 +++++++-- 2 files changed, 141 insertions(+), 76 deletions(-) diff --git a/app/Http/Controllers/Admin/ManageNotificationsController.php b/app/Http/Controllers/Admin/ManageNotificationsController.php index cf1a2ad..f60bcfe 100644 --- a/app/Http/Controllers/Admin/ManageNotificationsController.php +++ b/app/Http/Controllers/Admin/ManageNotificationsController.php @@ -81,78 +81,94 @@ class ManageNotificationsController extends Controller * Use : To add notification . */ public function store_notificaton_data(Request $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); - - // 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); + if (isset($request->image)) { + $image = $request->image; + $image_db = null; + } else { + $image = null; + $image_db = $request->image; } - } 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 - ); + $tnormalImage = saveSingleImageWithoutCrop($image, 'notification_images', $image_db); + $imagePath = ListingImageUrl('notification_images', $tnormalImage); + + $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); } - onesignalhelper::StoreNotificationDetails($restIdItem->id, 'Notification', $request->title, $imagePath); - } - } + } elseif ($request->user_type == 2) { + $allRestaurantOneSignalIds = $userQuery->pluck('id'); + $restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get(); - 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); + 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); + } + } elseif ($request->user_type == 3) { + $allUserOneSignalIds = $userQuery->pluck('id'); + $UserData = IamPrincipal::whereIn('id', $allUserOneSignalIds)->get(); + + foreach ($UserData as $userItem) { + if ($userItem->one_signal_player_id) { + onesignalhelper::sendNotificationApi( + $userItem->one_signal_player_id, + $request->title, + $request->description, + 'Dashboard Notification', + $imagePath, + $id = null + ); + } + onesignalhelper::StoreNotificationDetails($userItem->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_notifications_add.blade.php b/resources/views/Admin/pages/manage_notification/manage_notifications_add.blade.php index b7d5484..d71ef1b 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 @@ -71,13 +71,19 @@ users who are in their respective states
--> -
+ {{--

Subscription FAQs

@@ -93,7 +93,7 @@ @endforeach
-
+
--}}
- +
- +
@@ -107,8 +109,7 @@