From 963783ba288e108dbd2ce1cbb100cf3a310e3242 Mon Sep 17 00:00:00 2001 From: sayliraut Date: Tue, 18 Jun 2024 12:46:04 +0530 Subject: [PATCH] change --- .../Customer_API/FeedbackApiController.php | 3 + .../Admin/ManageNotificationsController.php | 14 +- .../APIs/CustomerAPIs/FeedbackApiServices.php | 4 +- ...02_063443_create_manage_feedback_table.php | 14 +- .../manage_notifications_add.blade.php | 136 ++++++++++++------ 5 files changed, 115 insertions(+), 56 deletions(-) diff --git a/app/Http/Controllers/Admin/APIs/Customer_API/FeedbackApiController.php b/app/Http/Controllers/Admin/APIs/Customer_API/FeedbackApiController.php index 96d597c..20fe50c 100644 --- a/app/Http/Controllers/Admin/APIs/Customer_API/FeedbackApiController.php +++ b/app/Http/Controllers/Admin/APIs/Customer_API/FeedbackApiController.php @@ -59,6 +59,9 @@ class FeedbackApiController extends Controller $token = readHeaderToken(); $validator = Validator::make($request->all(), [ 'reaction' => 'required|numeric', + 'is_app_feedback' => 'required|boolean', + 'is_restaurant_feedback' => 'required|boolean', + 'restaurant_id' => $request->input('is_restaurant_feedback') == 1 ? 'required|integer' : '', // 'comment' => 'required', ]); diff --git a/app/Http/Controllers/Admin/ManageNotificationsController.php b/app/Http/Controllers/Admin/ManageNotificationsController.php index 10cb55d..6d3ca6f 100644 --- a/app/Http/Controllers/Admin/ManageNotificationsController.php +++ b/app/Http/Controllers/Admin/ManageNotificationsController.php @@ -9,6 +9,7 @@ use Illuminate\Http\Request; use Exception; use Illuminate\Support\Facades\Log; use App\Helpers\onesignalhelper; +use App\Models\ManageState; use Illuminate\Support\Facades\DB; class ManageNotificationsController extends Controller @@ -70,7 +71,8 @@ class ManageNotificationsController extends Controller */ public function add() { - return view('Admin.pages.manage_notification.manage_notifications_add'); + $state = ManageState::where('is_active', 1)->get()->toArray(); + return view('Admin.pages.manage_notification.manage_notifications_add', compact('state')); } /** @@ -80,6 +82,7 @@ class ManageNotificationsController extends Controller */ public function store_notificaton_data(Request $request) { + dd($request); try { $request->validate([ 'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048', @@ -103,10 +106,12 @@ class ManageNotificationsController extends Controller $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', 4) + ->where('principal_type_xid', 3) + ->where('state_xid', $request->state) ->pluck('id'); @@ -118,7 +123,7 @@ class ManageNotificationsController extends Controller $imageUrl = $imagePath; // FOR all customer - if ($request->recipients == 'customer') { + if ($request->user_type == 1) { foreach ($UserData as $customerIdItem) { if ($customerIdItem->one_signal_player_id) { onesignalhelper::sendNotificationApi( @@ -132,7 +137,7 @@ class ManageNotificationsController extends Controller } onesignalhelper::StoreNotificationDetails($customerIdItem->id, $content_type, $title, $imagePath); } - } elseif ($request->recipients == 'restaurant') { + } elseif ($request->user_type == 2) { $restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get(); foreach ($restaurantData as $restIdItem) { @@ -171,5 +176,4 @@ class ManageNotificationsController extends Controller $notification = NotificationDetails::with('notification')->findOrFail($id); return view('Admin.pages.manage_notification.manage_notifications_view', compact('notification')); } - } diff --git a/app/Services/APIs/CustomerAPIs/FeedbackApiServices.php b/app/Services/APIs/CustomerAPIs/FeedbackApiServices.php index cf715a6..75c7b55 100644 --- a/app/Services/APIs/CustomerAPIs/FeedbackApiServices.php +++ b/app/Services/APIs/CustomerAPIs/FeedbackApiServices.php @@ -28,7 +28,9 @@ class FeedbackApiServices 'principal_xid' => $user_data->id, 'feedback_reaction_xid' => $reaction, 'comment' => $comment, - 'default_comment' => $request->default_comment, + 'is_app_feedback' => $request->is_app_feedback, + 'is_restaurant_feedback' => $request->is_restaurant_feedback, + 'restaurant_id' => $request->restaurant_id, ]; $feedback = ManageFeedback::create($feedbackData); diff --git a/database/migrations/2024_02_02_063443_create_manage_feedback_table.php b/database/migrations/2024_02_02_063443_create_manage_feedback_table.php index 53b62b4..9787c16 100644 --- a/database/migrations/2024_02_02_063443_create_manage_feedback_table.php +++ b/database/migrations/2024_02_02_063443_create_manage_feedback_table.php @@ -13,18 +13,22 @@ return new class extends Migration { Schema::create('manage_feedback', function (Blueprint $table) { $table->id(); - + // Foreign key references for principal $table->unsignedBigInteger('principal_xid'); $table->foreign('principal_xid')->references('id')->on('iam_principal')->onDelete('cascade'); - + // Feedback reaction and comment columns - + $table->unsignedBigInteger('feedback_reaction_xid'); $table->foreign('feedback_reaction_xid')->references('id')->on('feedback_reaction')->onDelete('cascade'); - + $table->longtext('comment')->nullable(); - + $table->boolean('is_app_feedback')->default(0); + $table->boolean('is_restaurant_feedback')->default(0); + $table->integer('restaurant_id')->nullable(); + + // Soft deletes, timestamps, and additional columns $table->softDeletes(); $table->timestamps(); 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 4db3116..3e73654 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 @@ -60,14 +60,40 @@ -
+
- - + +
+ +
+ +
+
+ +
@@ -87,43 +113,42 @@
@endsection - @section('section_script') - - + + @endsection