From 05dec2db37df0eac2ed60145474266025986e3f9 Mon Sep 17 00:00:00 2001 From: sayliraut Date: Mon, 22 Jul 2024 17:53:12 +0530 Subject: [PATCH] referral rule API --- .../APIs/Customer_API/RulesControllerAPI.php | 23 +++++++++++++++++++ .../APIs/CustomerAPIs/RulesApiServices.php | 16 +++++++++++++ .../manage_notifications_add.blade.php | 6 +++-- routes/customer_api.php | 1 + 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/APIs/Customer_API/RulesControllerAPI.php b/app/Http/Controllers/APIs/Customer_API/RulesControllerAPI.php index 53cd3bf..f23f1f8 100644 --- a/app/Http/Controllers/APIs/Customer_API/RulesControllerAPI.php +++ b/app/Http/Controllers/APIs/Customer_API/RulesControllerAPI.php @@ -38,4 +38,27 @@ class RulesControllerAPI extends Controller return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); } } + + /** + * Created By : sayli Raut + * Created at : 22 Jully 2024 + * Use : To get referral rules and regulation. + */ + + public function getReferralRules() + { + try { + $token = readHeaderToken(); + if ($token) { + $customerIamId = $token['sub']; + $response = $this->RulesApiServices->getReferralRules(); + return jsonResponseWithSuccessMessageApi(__('success.data_fetched_successfully'), $response, 200); + } else { + return jsonResponseWithErrorMessageApi(__('auth.user_deleted'), 409); + } + } catch (\Exception $e) { + Log::error('Referral rules get data controller function failed: ' . $e->getMessage()); + return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); + } + } } diff --git a/app/Services/APIs/CustomerAPIs/RulesApiServices.php b/app/Services/APIs/CustomerAPIs/RulesApiServices.php index a6c35e5..3724bbd 100644 --- a/app/Services/APIs/CustomerAPIs/RulesApiServices.php +++ b/app/Services/APIs/CustomerAPIs/RulesApiServices.php @@ -2,6 +2,7 @@ namespace App\Services\APIs\CustomerAPIs; +use App\Models\ManageReferralRule; use App\Models\ManageRule; use Illuminate\Support\Facades\Log; @@ -22,4 +23,19 @@ class RulesApiServices return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500); } } + + + public function getReferralRules() + { + try { + $data = ManageReferralRule::select('id', 'title', 'message') + ->get() + ->toArray(); + + return $data; + } catch (Exception $ex) { + Log::error('Voucher rules and regulation Get service failed : ' . $ex->getMessage()); + return jsonResponseWithErrorMessageApi(__('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 e251dae..ce9b4fd 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 @@ -135,10 +135,12 @@ @endforeach +
+
@@ -254,12 +256,12 @@ errorClass: 'error-message', errorPlacement: function(error, element) { if (element.attr("name") == "user_type") { - error.insertAfter("#select-ids").addClass('error-message'); + error.appendTo("#user_type_error").addClass('error-message'); } else if (element.attr("name") == "schedule_radio1") { error.insertAfter("#push_schedule_radi02").addClass('error-message'); } else if (element.attr("name") == "states[]") { error.insertAfter(`#dropdown-${$('input[name="user_type"]:checked').val()}`) - .addClass('error-message'); + error.appendTo("#user_type_error").addClass('error-message'); } else { error.insertAfter(element).addClass('error-message'); } diff --git a/routes/customer_api.php b/routes/customer_api.php index f70fc74..c34fc1d 100644 --- a/routes/customer_api.php +++ b/routes/customer_api.php @@ -94,6 +94,7 @@ Route::middleware(['customerApiBasicAuth'])->group(function () { //*******************************************************Rules ******************************************************** Route::get('/v1/voucher-rules', [RulesControllerAPI::class, 'getVoucherRules']); + Route::get('/v1/referral-rules', [RulesControllerAPI::class, 'getReferralRules']); });