From 4b0537af704d5ad36dec367afae3cc319176f042 Mon Sep 17 00:00:00 2001 From: sayliraut Date: Wed, 14 Aug 2024 13:15:59 +0530 Subject: [PATCH] changse --- .../APIs/Customer_API/StripeWebhookController.php | 10 +++++----- app/Models/SubscriptionProducts.php | 9 +++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/APIs/Customer_API/StripeWebhookController.php b/app/Http/Controllers/APIs/Customer_API/StripeWebhookController.php index d3a7688..871d506 100644 --- a/app/Http/Controllers/APIs/Customer_API/StripeWebhookController.php +++ b/app/Http/Controllers/APIs/Customer_API/StripeWebhookController.php @@ -182,7 +182,7 @@ class StripeWebhookController extends Controller ]); $id = Subscriptions::updateOrCreate( - ['iam_principal_xid' => $userId, + ['iam_principal_xid' => $userId, 'subscription_product_xid' => $subscriptionProductId], [ 'subscription_id' => $subscriptionData->subscription, @@ -246,7 +246,7 @@ class StripeWebhookController extends Controller Log::info($isCustomReferralCodeApplied); - + ReferralUsers::create([ @@ -262,7 +262,7 @@ class StripeWebhookController extends Controller $getUserData = IamPrincipal::where('id', $userId)->first(); $title = "Congratulations your subscription is now active"; - $message = $getUserData->first_name . " has subscribed for " . $subscriptionProductData->name; + $message = $getUserData->first_name . " has subscribed for " . $subscriptionProductData->product->product_name; $content_type = "new_subscription"; onesignalhelper::sendNotificationApi($getUserData->one_signal_player_id, $title, $message, $content_type, $image = null, $id = null); @@ -323,7 +323,7 @@ class StripeWebhookController extends Controller $title = "Congratulations your Subscription has been Renewed"; - $message = $iamPrincialData->first_name . " has subscribed for " . $subscriptionProductData->product_name; + $message = $iamPrincialData->first_name . " has subscribed for " . $subscriptionProductData->product->product_name; $content_type = "recurring_subscription"; onesignalhelper::sendNotificationApi($iamPrincialData->one_signal_player_id, $title, $message, $content_type, $image = null, $id = null); @@ -348,4 +348,4 @@ class StripeWebhookController extends Controller return response('Webhook received', 200); } -} \ No newline at end of file +} diff --git a/app/Models/SubscriptionProducts.php b/app/Models/SubscriptionProducts.php index 175fec7..78bbc24 100644 --- a/app/Models/SubscriptionProducts.php +++ b/app/Models/SubscriptionProducts.php @@ -11,7 +11,7 @@ class SubscriptionProducts extends Model protected $table = 'subscription_products'; protected $guarded = []; - + protected $fillable =[ 'id', 'product_name', @@ -26,5 +26,10 @@ class SubscriptionProducts extends Model 'created_at', 'updated_at' ]; - + + + public function product() + { + return $this->belongsTo(SubscriptionProducts::class, 'subscription_product_xid', 'id'); + } }