From 92b4b9947fa5bbe0e857105212d9fe70c14ad72f Mon Sep 17 00:00:00 2001 From: sayliraut Date: Tue, 11 Jun 2024 15:09:59 +0530 Subject: [PATCH] change --- .../Controllers/Admin/DashboardController.php | 14 +- .../Admin/ManageContactUsController.php | 11 ++ .../Admin/ManageFeedbackController.php | 5 + .../Admin/ManageNotificationsController.php | 170 +++++++++++++++- .../CustomerAPIs/RestaurantApiServices.php | 2 +- .../manage_notification.blade.php | 81 +++----- .../manage_notifications_add.blade.php | 185 ++++++++++++++++++ .../manage_notifications_view.blade.php | 83 ++++++++ routes/web.php | 4 + 9 files changed, 494 insertions(+), 61 deletions(-) create mode 100644 resources/views/Admin/pages/manage_notification/manage_notifications_add.blade.php create mode 100644 resources/views/Admin/pages/manage_notification/manage_notifications_view.blade.php diff --git a/app/Http/Controllers/Admin/DashboardController.php b/app/Http/Controllers/Admin/DashboardController.php index ac6f31b..e311f29 100644 --- a/app/Http/Controllers/Admin/DashboardController.php +++ b/app/Http/Controllers/Admin/DashboardController.php @@ -11,7 +11,7 @@ use App\Models\ManageRestaurant; class DashboardController extends Controller { - /** + /** * Created By : sayali parab * Created at : 16 May 2024 * Use : To show the dashboard. @@ -83,10 +83,14 @@ class DashboardController extends Controller $restaurantCount = ManageRestaurant::where('is_active', 1)->count(); return view('Admin.dashboard', compact( - 'customerCount', 'restaurantCount', 'dataMonthlyWithType3', 'dataMonthlyWithType4', - 'dataQuarterlyWithType3', 'dataQuarterlyWithType4', 'dataYearlyWithType3', 'dataYearlyWithType4' + 'customerCount', + 'restaurantCount', + 'dataMonthlyWithType3', + 'dataMonthlyWithType4', + 'dataQuarterlyWithType3', + 'dataQuarterlyWithType4', + 'dataYearlyWithType3', + 'dataYearlyWithType4' )); } - - } diff --git a/app/Http/Controllers/Admin/ManageContactUsController.php b/app/Http/Controllers/Admin/ManageContactUsController.php index 087f230..af827d5 100644 --- a/app/Http/Controllers/Admin/ManageContactUsController.php +++ b/app/Http/Controllers/Admin/ManageContactUsController.php @@ -32,6 +32,11 @@ class ManageContactUsController extends Controller return view('Admin.pages.manage_contact_us.manage_contact', compact('queries')); } + /** + * Created By : Sayli Raut + * Created at : 10 June 2024 + * Use : To send reply. + */ public function sendReply(Request $request) { if (!$request->user_id || $request->user_id == null) { @@ -63,6 +68,12 @@ class ManageContactUsController extends Controller } + + /** + * Created By : Sayli Raut + * Created at : 10 June 2024 + * Use : To delete query. + */ public function delete_user($id) { $data = ManageContactUs::find($id)->delete(); diff --git a/app/Http/Controllers/Admin/ManageFeedbackController.php b/app/Http/Controllers/Admin/ManageFeedbackController.php index 685f984..4c9bba1 100644 --- a/app/Http/Controllers/Admin/ManageFeedbackController.php +++ b/app/Http/Controllers/Admin/ManageFeedbackController.php @@ -24,6 +24,11 @@ class ManageFeedbackController extends Controller } + /** + * Created By : Sayli Raut + * Created at : 10 June 2024 + * Use : To delete query. + */ public function delete_feedback($id) { $data = ManageFeedback::find($id)->delete(); diff --git a/app/Http/Controllers/Admin/ManageNotificationsController.php b/app/Http/Controllers/Admin/ManageNotificationsController.php index 5518289..9fdae4d 100644 --- a/app/Http/Controllers/Admin/ManageNotificationsController.php +++ b/app/Http/Controllers/Admin/ManageNotificationsController.php @@ -3,13 +3,177 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; +use App\Models\NotificationDetails; use Illuminate\Http\Request; class ManageNotificationsController extends Controller { - public function index(){ - - return view('Admin.pages.manage_notification.manage_notification'); + public function index(Request $request) + { + /** + * Created By : Sayli Raut + * Created at : 11 June 2024 + * Use : To list notifications. + */ + $activeQuery = $request->query('active'); + if ($activeQuery == 4) { // for customer + $notifications = NotificationDetails::with('Notification') + ->whereHas('Notification', function ($query) { + $query->where('principal_type_xid', 3); + }) + ->latest() + ->take(12) + ->get(); + } else if ($activeQuery == 3) { // for restaurant + $notifications = NotificationDetails::with('Notification') + ->whereHas('Notification', function ($query) { + $query->where('principal_type_xid', 4); + }) + ->latest() + ->take(12) + ->get(); + + // return $notifications; + } else { + $notificationsOfType3 = NotificationDetails::with('Notification') + ->whereHas('Notification', function ($query) { + $query->where('principal_type_xid', 3); + }) + ->latest() + ->take(12) + ->get(); + + $notificationsOfType4 = NotificationDetails::with('Notification') + ->whereHas('Notification', function ($query) { + $query->where('principal_type_xid', 4); + }) + ->latest() + ->take(12) + ->get(); + + $notifications = $notificationsOfType3->merge($notificationsOfType4); + } + + return view('Admin.pages.manage_notification.manage_notification', compact('notifications')); + } + + /** + * Created By : Sayli Raut + * Created at : 10 June 2024 + * Use : To view notification details.s + */ + public function add() + { + return view('Admin.pages.manage_notification.manage_notifications_add'); + } + + /** + * Created By : Sayli Raut + * Created at : 10 June 2024 + * Use : To add notification . + */ + public function store_notificaton_data(Request $request) + { + try { + $request->validate([ + 'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048', + ]); + + 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); + $allOrders = Order::pluck('iam_principal_xid'); + $passportId = $request->passport; + $passportUserIds = OrderedPassport::where('passport_xid', $passportId) + ->whereHas('iamPrincipal', function ($query) { + $query->where('notification_status', 1) + ->where('principal_type_xid', 3); + }) + ->pluck('iam_principal_xid'); + + $passportUserIdsToArray = $passportUserIds->toArray(); + + $allCustomerOneSignalIds = IamPrincipal::where('is_active', 1) + ->where('notification_status', 1) + ->where('principal_type_xid', 3) + ->pluck('id'); + + // Find the remaining user IDs + $remainingUserIds = $allCustomerOneSignalIds->diff($allOrders); + $remainingUserIdsArray = $remainingUserIds->toArray(); + + // Find the remaining user data + $remainingUserData = IamPrincipal::whereIn('id', $remainingUserIdsArray)->get(); + $parchasePassportUserData = IamPrincipal::whereIn('id', $passportUserIdsToArray)->get(); + $title = $request->title; + $message = $request->description; + $content_type = 'Notification'; + $imageUrl = $imagePath; + + // FOR all User + if ($request->user_type == 1) { + foreach ($remainingUserData 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) { + foreach ($parchasePassportUserData 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); + } + } + + + // FOR All passport user + + + + DB::commit(); + return jsonResponseWithSuccessMessage(__('success.save_data')); + // return $voucher_data; + } catch (Exception $e) { + DB::rollBack(); + Log::error("Coupon Store Page Load Failed " . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + } + } + + + /** + * Created By : Sayli Raut + * Created at : 10 June 2024 + * Use : To view notification details.s + */ + public function view($id) + { + $notification = NotificationDetails::with('notification')->findOrFail($id); + return view('Admin.pages.manage_notification.manage_notifications_view', compact('notification')); } } diff --git a/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php b/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php index 0136f02..82e9d22 100644 --- a/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php +++ b/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php @@ -229,7 +229,7 @@ class RestaurantApiServices } // Check if there's an existing entry for the restaurant and update it - $restexist = RedeemRestaurant::where('manage_restaurants_xid', $restaurant->id)->first(); + $restexist = RedeemRestaurant::where('manage_restaurants_xid', $restaurant->id)->where('iam_principal_xid', $customerIamId)->first(); if ($restexist) { $restexist->is_redeem = 1; $restexist->redeem_date = now(); 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 7aa7131..a984e0e 100644 --- a/resources/views/Admin/pages/manage_notification/manage_notification.blade.php +++ b/resources/views/Admin/pages/manage_notification/manage_notification.blade.php @@ -29,6 +29,7 @@ Sr No. Notification content + Email Created Date Recipients Date sent @@ -36,12 +37,22 @@ + @foreach ($notifications as $notification) - 1 - Lorem Ipsum - 08/22/2023 - Customer - 20/22/2023 + {{ $loop->iteration }} + {{ $notification->type }} + {{ $notification->Notification->email_address }} + + {{ \Carbon\Carbon::parse($notification->created_at)->format('m/d/Y') }} + + @if ($notification->Notification->principal_type_xid == '3') + Customer + @else + Resturant + @endif + + + {{ \Carbon\Carbon::parse($notification->date_added)->format('m/d/Y') }}
- - 1 - Lorem Ipsum - 08/22/2023 - Customer - 20/22/2023 - -
- - -
- - - + @endforeach @@ -142,7 +119,7 @@ @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 new file mode 100644 index 0000000..b4fb170 --- /dev/null +++ b/resources/views/Admin/pages/manage_notification/manage_notifications_add.blade.php @@ -0,0 +1,185 @@ +@extends('admin.layouts.master') + +@section('content') + @php + $currentPage = 'manage_notification'; + @endphp + + +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ @csrf +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+ +
+
+
+
+
+
+ +
+
+
+@endsection + diff --git a/resources/views/Admin/pages/manage_notification/manage_notifications_view.blade.php b/resources/views/Admin/pages/manage_notification/manage_notifications_view.blade.php new file mode 100644 index 0000000..8101dfb --- /dev/null +++ b/resources/views/Admin/pages/manage_notification/manage_notifications_view.blade.php @@ -0,0 +1,83 @@ +@extends('Admin.layouts.master') + +@section('content') +@php +$currentPage = 'manage-notification'; +@endphp +
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+ + + + + + + + + + +
Notification content :Created Date :
{{ $notification->description }}{{ \Carbon\Carbon::parse($notification->date_added)->format('d/m/y') }}
+ +
+
+ + + + {{-- --}} + + + + + + + +
Recipients :Last Modified Date :
@if($notification->notification->principal_type_xid == '3') + Customer + @else + Resturant + @endif +
+
+
+ +
+
+ +
+ + +
+ +
+
+
+
+
+ + + +@endsection + diff --git a/routes/web.php b/routes/web.php index c414da9..8f10511 100644 --- a/routes/web.php +++ b/routes/web.php @@ -149,6 +149,10 @@ Route::group(['middleware' => ['checkStatus']], function () { //*******************************************************manage notification******************************************************** Route::get('/manage-notification', [ManageNotificationsController::class, 'index'])->name('manage.notification'); + Route::get('/manage_add_notifications', [ManageNotificationsController::class, 'add'])->name('manage_add_notifications'); + Route::post('/insert_notification', [ManageNotificationsController::class, 'store_notificaton_data']); + Route::get('/manage_view_notifications/{id}', [ManageNotificationsController::class, 'view']); + //*******************************************************manage restraunts********************************************************