From 6cbbde9834229b644775c5d10e75ec8ab38f376a Mon Sep 17 00:00:00 2001 From: adonis Date: Tue, 2 Jun 2026 15:25:16 +0330 Subject: [PATCH] handled refer_id for jbit --- .../Controllers/Customer/CustomerController.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Customer/CustomerController.php b/app/Http/Controllers/Customer/CustomerController.php index ee0be6c..998b100 100644 --- a/app/Http/Controllers/Customer/CustomerController.php +++ b/app/Http/Controllers/Customer/CustomerController.php @@ -197,10 +197,15 @@ class CustomerController extends Controller $companyName = $this->Config('name_fa'); $companyurl = $this->Config('app_url'); $referrer = $customer->referral; - $total_referrals = Customer::where('referral_to_id', $referrer->referral_id)->where('is_legal', '!=', 0)->get()->count(); - $referral_limit = Setting::where('key', 'referral_limit')->first(); - $gift_permision = $referral_limit->is_active ? $total_referrals < $referral_limit->value ? true : false : true ; - if ($gift_permision && $gift_for_inviter > 0) { + $gift_permision = true; + if ($referrer) { + $total_referrals = Customer::where('referral_to_id', $referrer->referral_id)->where('is_legal', '!=', 0)->count(); + $referral_limit = Setting::where('key', 'referral_limit')->first(); + $gift_permision = $referral_limit && $referral_limit->is_active + ? $total_referrals < $referral_limit->value + : true; + } + if ($referrer && $gift_permision && $gift_for_inviter > 0) { // dd($gift_for_inviter > 0, $gift_for_invited > 0); $Withdraw = Withdraw::create([ @@ -273,7 +278,7 @@ class CustomerController extends Controller $transaction = Transaction::where('customer_id', $customer->id)->latest()->first(); TransactionsAdmin::create([ 'customer_id' => $customer->id, - 'customer_to_id' => $customer->referal->id, + 'customer_to_id' => $customer->id, 'user_id' => $customer->id, 'wallet' => null, // یا مقدار مناسب دیگری 'transaction_id' => $transaction->id,