function updateTeamVolume($user_id, $amount) { $user = User::find($user_id); if (!$user || !$user->ref_by) return; $curr = $user->ref_by; // Prevent infinite loops if cycle exists (shouldn't in tree) $safeguard = 0; while ($curr && $curr != 0 && $safeguard < 100) { $upline = User::find($curr); if (!$upline) break; $upline->team_volume += $amount; $upline->save(); updateRank($upline->id); $curr = $upline->ref_by; $safeguard++; } } function updateRank($user_id) { $user = User::find($user_id); if (!$user) return; $currentRank = $user->rank; $newRank = $currentRank; // Active Directs: Users referred by this user who have active_invest > 0 $activeDirects = User::where('ref_by', $user->id)->where('active_invest', '>', 0)->count(); $teamVol = $user->team_volume; // Rank 2: Builder (3 directs, 500 vol) if ($activeDirects >= 3 && $teamVol >= 500) { if ($newRank < 2) $newRank = 2; } // Rank 3: Leader (5 directs, 2000 vol) if ($activeDirects >= 5 && $teamVol >= 2000) { if ($newRank < 3) $newRank = 3; } // Rank 4: Manager (10 directs, 10000 vol) if ($activeDirects >= 10 && $teamVol >= 10000) { if ($newRank < 4) $newRank = 4; } // Rank 5: Director (20 directs, 50000 vol) if ($activeDirects >= 20 && $teamVol >= 50000) { if ($newRank < 5) $newRank = 5; } // Rank 6: Executive (3 Directors in separate legs) if ($newRank >= 5) { $legsWithDirector = 0; $directs = User::where('ref_by', $user->id)->get(); foreach ($directs as $direct) { // Check if direct is Director or higher if ($direct->rank >= 5) { $legsWithDirector++; } } if ($legsWithDirector >= 3) { if ($newRank < 6) $newRank = 6; } } if ($newRank > $currentRank) { $user->rank = $newRank; // One-time bonuses if ($newRank == 3 && $currentRank < 3) { addRankBonus($user, 150, 'Rank 3 Bonus (Leader)'); } $user->save(); // Notify user notify($user, 'RANK_UPDATE', [ 'rank' => $newRank, ]); } } function addRankBonus($user, $amount, $remark) { $user->balance += $amount; $user->total_rank_reward += $amount; $user->save(); $trx = new Transaction(); $trx->user_id = $user->id; $trx->amount = $amount; $trx->charge = 0; $trx->trx_type = '+'; $trx->details = $remark; $trx->remark = 'rank_bonus'; $trx->trx = getTrx(); $trx->post_balance = $user->balance; $trx->save(); } function distributeMatchingBonus($user_id, $roi_amount) { $user = User::find($user_id); if (!$user || !$user->ref_by) return; $curr = $user->ref_by; $level = 1; while ($curr && $curr != 0 && $level <= 3) { $upline = User::find($curr); if (!$upline) break; $percentage = 0; // Rank-gated levels if ($level == 1) { // Level 1: 5%. Rank 2+ if ($upline->rank >= 2) $percentage = 5; } elseif ($level == 2) { // Level 2: 3%. Rank 3+ if ($upline->rank >= 3) $percentage = 3; } elseif ($level == 3) { // Level 3: 2%. Rank 4+ if ($upline->rank >= 4) $percentage = 2; } if ($percentage > 0) { $bonus = ($roi_amount * $percentage) / 100; if ($bonus > 0) { $upline->balance += $bonus; $upline->total_matching_bonus += $bonus; $upline->save(); $trx = new Transaction(); $trx->user_id = $upline->id; $trx->amount = $bonus; $trx->charge = 0; $trx->trx_type = '+'; $trx->details = 'Matching Bonus Level ' . $level . ' from ' . $user->username; $trx->remark = 'matching_bonus'; $trx->trx = getTrx(); $trx->post_balance = $upline->balance; $trx->save(); } } $curr = $upline->ref_by; $level++; } } Laravel
Internal Server Error
Error
Call to undefined function App\Providers\activeTemplate()
app/Providers/AppServiceProvider.php :50
vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php :36
vendor/laravel/framework/src/Illuminate/Container/Util.php :41
vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php :93
vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php :35
vendor/laravel/framework/src/Illuminate/Container/Container.php :690
vendor/laravel/framework/src/Illuminate/Foundation/Application.php :1119
vendor/laravel/framework/src/Illuminate/Foundation/Application.php :1100
vendor/laravel/framework/src/Illuminate/Foundation/Application.php :1099
vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php :17
vendor/laravel/framework/src/Illuminate/Foundation/Application.php :316
vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php :186
vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php :170
vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php :144
vendor/laravel/framework/src/Illuminate/Foundation/Application.php :1188
/home/freedemo/public_html/test1.freedemosite.xyz/index.php :17
Request
GET /
Headers
accept
*/*
accept-encoding
gzip, br, zstd, deflate
host
www.test1.freedemosite.xyz
user-agent
Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Body
No body data
Application
Routing
No routing data
Database Queries
No query data