wip more dashboard widgets
This commit is contained in:
@@ -58,17 +58,33 @@
|
||||
@if (!$user->portfolios->isEmpty())
|
||||
<x-ib-card title="{{ __('Top performers') }}" class="md:col-span-3">
|
||||
|
||||
@php
|
||||
$users = App\Models\User::take(3)->get();
|
||||
@endphp
|
||||
|
||||
@foreach($users as $user)
|
||||
<x-list-item no-separator :item="$user" avatar="profile_photo_url" link="/docs/installation" />
|
||||
@foreach($user->holdings->sortBy('market_gain_percent')->where('quantity', '>', 0)->take(5) as $holding)
|
||||
<x-list-item no-separator :item="$holding" link="{{ route('portfolio.show', ['portfolio' => $holding->portfolio_id]) }}">
|
||||
|
||||
@php
|
||||
$gainPercent = (($holding->market_data?->market_value - $holding->average_cost_basis) / $holding->average_cost_basis) * 100;
|
||||
@endphp
|
||||
|
||||
<x-slot:value class="flex items-center">
|
||||
|
||||
{{ $holding->symbol }}
|
||||
|
||||
<x-badge class="{{ $gainPercent > 0 ? 'badge-success' : 'badge-error' }} ml-2 badge-sm" >
|
||||
<x-slot:value>
|
||||
{{ Number::percentage($gainPercent) }}
|
||||
</x-slot:value>
|
||||
</x-badge>
|
||||
|
||||
</x-slot:value>
|
||||
<x-slot:sub-value>
|
||||
{{ $holding->market_data?->name }}
|
||||
</x-slot:sub-value>
|
||||
</x-list-item>
|
||||
@endforeach
|
||||
|
||||
</x-ib-card>
|
||||
@endif
|
||||
|
||||
|
||||
{{-- @if (!$user->portfolios->isEmpty())
|
||||
<x-ib-card title="{{ __('Top headlines') }}" class="md:col-span-3">
|
||||
|
||||
@@ -83,20 +99,6 @@
|
||||
</x-ib-card>
|
||||
@endif --}}
|
||||
|
||||
@if (!$user->portfolios->isEmpty())
|
||||
<x-ib-card title="{{ __('Recent activity') }}" class="md:col-span-4">
|
||||
|
||||
@php
|
||||
$users = App\Models\User::take(3)->get();
|
||||
@endphp
|
||||
|
||||
@foreach($users as $user)
|
||||
<x-list-item no-separator :item="$user" avatar="profile_photo_url" link="/docs/installation" />
|
||||
@endforeach
|
||||
|
||||
</x-ib-card>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
</x-app-layout>
|
||||
@@ -61,5 +61,42 @@ new class extends Component {
|
||||
|
||||
<div class="">
|
||||
|
||||
<x-table wire:loading.remove :headers="$headers" :rows="$this->holdings()" :sort-by="$sortBy" />
|
||||
<x-table wire:loading.remove :headers="$headers" :rows="$this->holdings()" :sort-by="$sortBy">
|
||||
@scope('cell_average_cost_basis', $row)
|
||||
{{ Number::currency($row->average_cost_basis ?? 0) }}
|
||||
@endscope
|
||||
@scope('cell_total_cost_basis', $row)
|
||||
{{ Number::currency($row->total_cost_basis ?? 0) }}
|
||||
@endscope
|
||||
@scope('cell_realized_gain_dollars', $row)
|
||||
{{ Number::currency($row->realized_gain_dollars ?? 0) }}
|
||||
@endscope
|
||||
@scope('cell_market_gain_dollars', $row)
|
||||
{{ Number::currency($row->market_gain_dollars ?? 0) }}
|
||||
@endscope
|
||||
@scope('cell_market_gain_percent', $row)
|
||||
{{ Number::percentage($row->market_gain_percent ?? 0) }}
|
||||
@endscope
|
||||
@scope('cell_market_data_market_value', $row)
|
||||
{{ Number::currency($row->market_data_market_value ?? 0) }}
|
||||
@endscope
|
||||
@scope('cell_market_data_fifty_two_week_low', $row)
|
||||
{{ Number::currency($row->market_data_fifty_two_week_low ?? 0) }}
|
||||
@endscope
|
||||
@scope('cell_market_data_fifty_two_week_high', $row)
|
||||
{{ Number::currency($row->market_data_fifty_two_week_high ?? 0) }}
|
||||
@endscope
|
||||
@scope('cell_total_market_value', $row)
|
||||
{{ Number::currency($row->total_market_value ?? 0) }}
|
||||
@endscope
|
||||
@scope('cell_dividends_earned', $row)
|
||||
{{ Number::currency($row->dividends_earned ?? 0) }}
|
||||
@endscope
|
||||
@scope('cell_dividends_earned', $row)
|
||||
{{ Number::currency($row->dividends_earned ?? 0) }}
|
||||
@endscope
|
||||
@scope('cell_market_data_updated_at', $row)
|
||||
{{ \Carbon\Carbon::parse($row->market_data_updated_at)->diffForHumans() }}
|
||||
@endscope
|
||||
</x-table>
|
||||
</div>
|
||||
@@ -43,10 +43,11 @@ new class extends Component {
|
||||
$dailyChangeQuery->selectRaw('date,
|
||||
SUM(total_market_value) as total_market_value,
|
||||
SUM(total_cost_basis) as total_cost_basis,
|
||||
SUM(total_gain) as total_gain,
|
||||
SUM(total_dividends_earned) as total_dividends_earned,
|
||||
SUM(realized_gains) as realized_gains'
|
||||
SUM(total_gain) as total_gain'
|
||||
)->groupBy('date');
|
||||
|
||||
// SUM(total_dividends_earned) as total_dividends_earned,
|
||||
// SUM(realized_gains) as realized_gains
|
||||
}
|
||||
|
||||
if ($filterMethod['method']) {
|
||||
@@ -70,14 +71,14 @@ new class extends Component {
|
||||
'name' => __('Market Gain'),
|
||||
'data' => $dailyChange->map(fn($data) => [$data->date, $data->total_gain])->toArray()
|
||||
],
|
||||
[
|
||||
'name' => __('Dividends Earned'),
|
||||
'data' => $dailyChange->map(fn($data) => [$data->date, $data->total_dividends_earned])->toArray()
|
||||
],
|
||||
[
|
||||
'name' => __('Realized Gains'),
|
||||
'data' => $dailyChange->map(fn($data) => [$data->date, $data->realized_gains])->toArray()
|
||||
],
|
||||
// [
|
||||
// 'name' => __('Dividends Earned'),
|
||||
// 'data' => $dailyChange->map(fn($data) => [$data->date, $data->total_dividends_earned])->toArray()
|
||||
// ],
|
||||
// [
|
||||
// 'name' => __('Realized Gains'),
|
||||
// 'data' => $dailyChange->map(fn($data) => [$data->date, $data->realized_gains])->toArray()
|
||||
// ],
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -81,29 +81,15 @@
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mt-6 grid md:grid-cols-7 gap-5">
|
||||
|
||||
<x-ib-card title="{{ __('Holdings') }}" class="md:col-span-4">
|
||||
|
||||
|
||||
@livewire('holdings-table', [
|
||||
'portfolio' => $portfolio
|
||||
])
|
||||
|
||||
</x-ib-card>
|
||||
|
||||
{{-- <x-ib-card title="{{ __('Top performers') }}" class="md:col-span-3">
|
||||
|
||||
@php
|
||||
$users = App\Models\User::take(3)->get();
|
||||
@endphp
|
||||
|
||||
@foreach($users as $user)
|
||||
<x-list-item no-separator :item="$user" avatar="profile_photo_url" link="/docs/installation" />
|
||||
@endforeach
|
||||
|
||||
</x-ib-card> --}}
|
||||
|
||||
{{-- <x-ib-card title="{{ __('Top headlines') }}" class="md:col-span-3">
|
||||
|
||||
@@ -125,6 +111,34 @@
|
||||
|
||||
</x-ib-card>
|
||||
|
||||
<x-ib-card title="{{ __('Top performers') }}" class="md:col-span-3">
|
||||
|
||||
@foreach($portfolio->holdings->sortBy('market_gain_percent')->where('quantity', '>', 0)->take(5) as $holding)
|
||||
<x-list-item no-separator :item="$holding">
|
||||
|
||||
@php
|
||||
$gainPercent = (($holding->market_data?->market_value - $holding->average_cost_basis) / $holding->average_cost_basis) * 100;
|
||||
@endphp
|
||||
|
||||
<x-slot:value class="flex items-center">
|
||||
|
||||
{{ $holding->symbol }}
|
||||
|
||||
<x-badge class="{{ $gainPercent > 0 ? 'badge-success' : 'badge-error' }} ml-2 badge-sm" >
|
||||
<x-slot:value>
|
||||
{{ Number::percentage($gainPercent) }}
|
||||
</x-slot:value>
|
||||
</x-badge>
|
||||
|
||||
</x-slot:value>
|
||||
<x-slot:sub-value>
|
||||
{{ $holding->market_data?->name }}
|
||||
</x-slot:sub-value>
|
||||
</x-list-item>
|
||||
@endforeach
|
||||
|
||||
</x-ib-card>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
Reference in New Issue
Block a user