@php use Illuminate\Support\Facades\DB; use App\Models\DepositCoin; use Illuminate\Support\Facades\Cache; function getCurrencyByCoin($id) { // Try to retrieve the coins from the cache $coins = Cache::get('coins'); // If coins are not in the cache, retrieve them from the database and cache them if (!$coins) { $coins = DepositCoin::all(); Cache::forever('coins', $coins); } // Find and return the coin by ID $coin = $coins->find($id); return $coin; } $startDate = now()->subDays(6); $endDate = now(); $deposit_data = user() ->deposits() ->selectRaw('DATE(created_at) as date, SUM(amount) as total_deposit') ->whereBetween('created_at', [$startDate, $endDate]) ->groupBy('date') ->orderBy('date') ->get(); $withdrawal_data = user() ->withdrawals() ->selectRaw('DATE(created_at) as date, SUM(amount) as total_withdrawal') ->whereBetween('created_at', [$startDate, $endDate]) ->groupBy('date') ->orderBy('date') ->get(); $graph_info = []; $days = []; $deposit_amount = []; $deposits_graph = []; $withdrawals_graph = []; // Create an associative array with all days within the date range and initial values of 0 $currentDate = $startDate; while ($currentDate <= $endDate) { $formatted_date = $currentDate->format('d-m'); $graph_info[$formatted_date] = ['deposit' => 0, 'withdrawal' => 0]; $currentDate->addDay(); array_push($days, $formatted_date); } // Populate the graph_info array with actual data from $chart_data foreach ($deposit_data as $data) { $formatted_date = date('d-m', strtotime($data->date)); // $graph_info[$formatted_date] = [ // 'deposit' => $data->total_deposit, // ]; $graph_info[$formatted_date]['deposit'] = $data->total_deposit; } foreach ($withdrawal_data as $data) { $formatted_date = date('d-m', strtotime($data->date)); // $graph_info[$formatted_date] = [ // 'withdrawal' => $data->total_withdrawal, // ]; $graph_info[$formatted_date]['withdrawal'] = $data->total_withdrawal; } foreach ($graph_info as $day => $data) { array_push($days, $day); array_push($deposits_graph, $data['deposit']); array_push($withdrawals_graph, $data['withdrawal']); } $days = array_slice($days, -7); //////////////////////////////// merge deposit and wihdrawal // Merge both collections and sort by created_at $user_id = user()->id; $deposits_blade = DB::select("SELECT * FROM deposits WHERE user_id = $user_id ORDER BY id DESC LIMIT 5"); $withdrawals_blade = DB::select("SELECT * FROM withdrawals WHERE user_id = $user_id ORDER BY id DESC LIMIT 5"); $deposits_and_withdrawals = collect(array_merge((array) $deposits_blade, (array) $withdrawals_blade)); // Sort the combined collection by 'created_at' in descending order $deposits_and_withdrawals = $deposits_and_withdrawals->sortByDesc('created_at'); // Now $deposits_and_withdrawals contains a combined collection of deposits and withdrawals ordered by 'created_at' // Corrected dd() to dump the correct variables //dd($deposits_and_withdrawals, $deposits_blade, $withdrawals_blade); @endphp @extends('templates.' . site('template') . '.layouts.user') @section('css') @endsection @section('contents') {{-- Al Trading View chart --}}

AI Trading Overview (7 Day PNL)

{{-- WALLET START --}}
icon Account

{{ formatAmount(user()->balance) }}

{{-- @if ($percentage_deposit_increase > 0) + {{ round($percentage_deposit_increase, 2) }}% @else +0% @endif --}} @if ($percentage_deposit_increase == 0)
icon @if ($percentage_deposit_increase > 0) + {{ round($percentage_deposit_increase, 2) }}% @else 0% @endif
@elseif($percentage_deposit_increase > 0)
icon @if ($percentage_deposit_increase > 0) + {{ round($percentage_deposit_increase, 2) }}% @else 0% @endif
@else
icon @if ($percentage_deposit_increase > 0) + {{ round($percentage_deposit_increase, 2) }}% @else 0% @endif
@endif
@if ($percentage_deposit_increase == 0) wave @elseif($percentage_deposit_increase > 0) wave @else wave @endif
icon All Time PNL

{{ formatAmount($profit_fig + $capital) }}

@if ($profit_percent == 0)
icon +{{ number_format($profit_percent, 2) }}%
@elseif($profit_percent > 0)
icon +{{ number_format($profit_percent, 2) }}%
@else
icon {{ number_format($profit_percent, 2) }}%
@endif
@if ($profit_percent == 0) wave @elseif($profit_percent > 0) wave @else wave @endif
icon Ai Bots

No of Bots

{{ user()->botActivations()->count() }}

@php $tradeCount = user()->botHistory()->count(); @endphp @if ($tradeCount <= 0)
icon {{ user()->botHistory()->count() }} trades
@elseif($tradeCount > 0)
icon +{{ user()->botHistory()->count() }} trades
@endif
@if ($tradeCount <= 0) wave @elseif($tradeCount > 0) wave @endif
{{-- my bots and recent trades --}}

My Bots

My Bots

Portfolio Balance

@forelse ($activations as $bot)
bots

{{ $bot->bot->name }} @if ($bot->status == 'active') @else @endif

PNL @if ($bot->profit < 0) {{ round(($bot->profit / ($bot->capital + 0.0001)) * 100, 2) }}% @else +{{ round(($bot->profit / ($bot->capital + 0.0001)) * 100, 2) }}% @endif

{{ formatAmount($bot->balance) }}
@empty

Empty Record. No Record found!

@endforelse

My Recent trades

@forelse ($histories as $history) @if ($history->profit < 0) @else @endif @empty

Empty Record. No Record found!

@endforelse
AI Bots Trading Pairs Profit/Loss
bots

{{ $history->botActivation->bot->name }}

clock{{ date('d-m-y', $history->timestamp) }} clock{{ date('H:i:s', $history->timestamp) }}

{{ $history->pair }}

{{ number_format((($history->exit_price - $history->entry_price) / $history->entry_price) * 100, 2) }}%

{{ formatAmount(str_replace('-', '', $history->profit)) }}

{{ $history->pair }}

+{{ number_format((($history->exit_price - $history->entry_price) / $history->entry_price) * 100, 2) }}%

+{{ formatAmount(str_replace('-', '', $history->profit)) }}

{{-- my history --}}

My History

@forelse ($deposits_and_withdrawals as $allData) @empty @endforelse
AI Bots/ID Holdings Date Time
coin

{{ getCurrencyByCoin($allData->deposit_coin_id)->name }}

{{ $allData->wallet_address ?? $allData->payment_wallet }}

{{ formatAmount($allData->amount) }}

{{ $allData->converted_amount }} {{ getCurrencyByCoin($allData->deposit_coin_id)->code }}/ {{ getCurrencyByCoin($allData->deposit_coin_id)->network ?? getCurrencyByCoin($allData->deposit_coin_id)->code }}

{{ date('d-m-y', strtotime($allData->created_at)) }}

{{ date('H:i:s A', strtotime($allData->created_at)) }}

@if ($allData->status == 'pending')

{{ $allData->status }}

@elseif ($allData->status == 'approved' || $allData->status == 'finished')

{{ $allData->status }}

@elseif ($allData->status == 'rejected' || $allData->status == 'failed' || $allData->status == 'refunded')

{{ $allData->status }}

@else

{{ $allData->status }}

@endif
Empty Record. No Record found!
@endsection @section('scripts') @endsection