layout cleanup
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Portfolio;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PortfolioController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('portfolio.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Portfolio $portfolio)
|
||||
{
|
||||
return view('portfolio.show', compact('portfolio'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,15 +3,40 @@
|
||||
namespace App\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class AppLayout extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represents the component.
|
||||
*/
|
||||
public function render(): View
|
||||
public function render()
|
||||
{
|
||||
return view('layouts.app-layout');
|
||||
return <<<'HTML'
|
||||
<x-main-layout>
|
||||
<x-slot:body class="min-h-screen font-sans antialiased bg-base-200/50 dark:bg-base-200" x-data>
|
||||
|
||||
<div>
|
||||
<x-partials.nav-bar />
|
||||
|
||||
<x-main with-nav full-width>
|
||||
|
||||
<x-slot:sidebar drawer="main-drawer" class="bg-base-100 lg:bg-inherit">
|
||||
|
||||
<x-partials.side-bar />
|
||||
|
||||
</x-slot:sidebar>
|
||||
|
||||
<x-slot:content>
|
||||
{{ $slot }}
|
||||
</x-slot:content>
|
||||
|
||||
</x-main>
|
||||
|
||||
<x-toast />
|
||||
</div>
|
||||
|
||||
</x-slot:body>
|
||||
</x-main-layout>
|
||||
HTML;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,15 +3,24 @@
|
||||
namespace App\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class GuestLayout extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represents the component.
|
||||
*/
|
||||
public function render(): View
|
||||
public function render()
|
||||
{
|
||||
return view('layouts.guest-layout');
|
||||
return <<<'HTML'
|
||||
<x-main-layout>
|
||||
<x-slot:body class="font-sans text-gray-900 dark:text-gray-100 antialiased">
|
||||
|
||||
{{ $slot }}
|
||||
|
||||
<x-theme-toggle class="hidden" darkTheme="business" lightTheme="corporate"/>
|
||||
|
||||
</x-slot:body>
|
||||
</x-main-layout>
|
||||
HTML;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace App\View\Components;
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class CommonLayout extends Component
|
||||
class MainLayout extends Component
|
||||
{
|
||||
public function __construct(
|
||||
|
||||
@@ -18,6 +18,6 @@ class CommonLayout extends Component
|
||||
*/
|
||||
public function render(): View
|
||||
{
|
||||
return view('layouts.common');
|
||||
return view('layouts.main-layout');
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<x-common-layout>
|
||||
<x-slot:body class="min-h-screen font-sans antialiased bg-base-200/50 dark:bg-base-200" x-data>
|
||||
|
||||
<div>
|
||||
<x-partials.nav-bar />
|
||||
|
||||
<x-main with-nav full-width>
|
||||
|
||||
<x-slot:sidebar drawer="main-drawer" class="bg-base-100 lg:bg-inherit">
|
||||
|
||||
<x-partials.side-bar />
|
||||
|
||||
</x-slot:sidebar>
|
||||
|
||||
<x-slot:content>
|
||||
{{ $slot }}
|
||||
</x-slot:content>
|
||||
|
||||
</x-main>
|
||||
|
||||
<x-toast />
|
||||
</div>
|
||||
|
||||
</x-slot:body>
|
||||
</x-common-layout>
|
||||
@@ -1,9 +0,0 @@
|
||||
<x-common-layout>
|
||||
<x-slot:body class="font-sans text-gray-900 dark:text-gray-100 antialiased">
|
||||
|
||||
{{ $slot }}
|
||||
|
||||
<x-theme-toggle class="hidden" darkTheme="business" lightTheme="corporate"/>
|
||||
|
||||
</x-slot:body>
|
||||
</x-common-layout>
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
{{-- <!DOCTYPE html> --}}
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
+4
-1
@@ -43,7 +43,10 @@ new class extends Component {
|
||||
// $this->portfolio->owner_id = auth()->user()->id;
|
||||
$this->portfolio->save();
|
||||
|
||||
$this->success('Portfolio updated', redirectTo: "/portfolio/{$this->portfolio->id}");
|
||||
$this->success('Portfolio updated');
|
||||
|
||||
$this->dispatch('portfolio-updated', $this->portfolio);
|
||||
$this->dispatch('close-drawer');
|
||||
}
|
||||
|
||||
public function save()
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Portfolio;
|
||||
use Livewire\Attributes\{Title, Rule};
|
||||
use Livewire\Volt\Component;
|
||||
|
||||
new class extends Component {
|
||||
|
||||
public bool $showDrawer2 = false;
|
||||
|
||||
public ?Portfolio $portfolio;
|
||||
|
||||
}; ?>
|
||||
<div>
|
||||
|
||||
<x-ib-toolbar title="Create Portfolio" />
|
||||
|
||||
<livewire:portfolio.manage-portfolio-form submit="save" />
|
||||
</div>
|
||||
@@ -1,223 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Portfolio;
|
||||
use Livewire\Attributes\{Title, Rule};
|
||||
use Livewire\Volt\Component;
|
||||
|
||||
new class extends Component {
|
||||
|
||||
public bool $showDrawer2 = false;
|
||||
public $scope = 'YTD';
|
||||
|
||||
public function changeScope ($scope)
|
||||
{
|
||||
$this->scope = $scope;
|
||||
}
|
||||
|
||||
public function getScopeName ($scope)
|
||||
{
|
||||
return collect($this->options)->where('id', $scope)['name'];
|
||||
}
|
||||
|
||||
public $options = [
|
||||
['id' => '1M', 'name' => '1 month'],
|
||||
['id' => '3M', 'name' => '3 months'],
|
||||
['id' => 'YTD', 'name' => 'Year to date'],
|
||||
['id' => '1Y', 'name' => '1 year'],
|
||||
['id' => '3Y', 'name' => '3 years'],
|
||||
['id' => 'ALL', 'name' => 'All time']
|
||||
];
|
||||
|
||||
public ?Portfolio $portfolio;
|
||||
|
||||
private function generateDateSeries($startDate, $endDate) {
|
||||
$dateArray = [];
|
||||
$currentDate = strtotime($startDate);
|
||||
$endDate = strtotime($endDate);
|
||||
|
||||
while ($currentDate <= $endDate) {
|
||||
// Generate a random integer
|
||||
$randomInt = rand(1000, 3000);
|
||||
|
||||
// Format the current date to 'Y-m-d'
|
||||
$formattedDate = date('Y-m-d', $currentDate);
|
||||
|
||||
// Append the date and random integer to the array
|
||||
$dateArray[] = [$formattedDate, $randomInt];
|
||||
|
||||
// Move to the next day
|
||||
$currentDate = strtotime("+1 day", $currentDate);
|
||||
}
|
||||
|
||||
return $dateArray;
|
||||
}
|
||||
|
||||
public array $myChart;
|
||||
|
||||
public function mount() {
|
||||
|
||||
$this->myChart = [
|
||||
'series' => [
|
||||
[
|
||||
'name' => 'Total Views',
|
||||
'data' => $this->generateDateSeries('2024-01-01', '2024-08-01')
|
||||
],
|
||||
[
|
||||
'name' => 'Second Views',
|
||||
'data' => $this->generateDateSeries('2024-01-01', '2024-08-01')
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<div x-data>
|
||||
|
||||
<x-ib-drawer
|
||||
key="manage-portfolio"
|
||||
title="{{ $portfolio->title }}"
|
||||
>
|
||||
|
||||
<livewire:portfolio.manage-portfolio-form :portfolio="$portfolio" submit="update" hide-cancel />
|
||||
|
||||
</x-ib-drawer>
|
||||
|
||||
<x-ib-toolbar :title="$portfolio->title">
|
||||
|
||||
@if($portfolio->wishlist)
|
||||
<x-badge value="Wishlist" class="badge-primary mr-3" />
|
||||
@endif
|
||||
|
||||
<x-button
|
||||
title="Edit Portfolio"
|
||||
icon="o-pencil"
|
||||
class="btn-circle btn-ghost btn-sm text-secondary"
|
||||
@click="$dispatch('toggle-manage-portfolio')"
|
||||
/>
|
||||
</x-ib-toolbar>
|
||||
|
||||
<x-card class="bg-slate-100 dark:bg-base-200 rounded-lg mb-6">
|
||||
|
||||
<div class="flex justify-between items-center mb-2">
|
||||
|
||||
<div class="flex items-center">
|
||||
|
||||
<h2 class="text-xl mr-4">Performance</h2>
|
||||
<div id="chart-legend-portfolio-{{ $portfolio->id }}" class="flex space-around"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<x-dropdown label="{{ $scope }}" class="btn-ghost btn-sm" >
|
||||
|
||||
<x-menu >
|
||||
@foreach($options as $option)
|
||||
|
||||
<x-menu-item
|
||||
title="{{ $option['name'] }}"
|
||||
x-on:click="$wire.changeScope('{{ $option['id'] }}')"
|
||||
/>
|
||||
|
||||
@endforeach
|
||||
</x-menu>
|
||||
</x-dropdown>
|
||||
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="h-[280px] mb-5"
|
||||
|
||||
>
|
||||
<x-ib-apex-chart :series-data="$myChart" :key="Str::uuid()" name="portfolio-{{ $portfolio->id }}" />
|
||||
</div>
|
||||
|
||||
</x-card>
|
||||
|
||||
<div class="grid md:grid-cols-5 gap-5">
|
||||
<x-stat
|
||||
class="bg-slate-100 dark:bg-base-200"
|
||||
title="Market Gain/Loss"
|
||||
value="22.124"
|
||||
icon="o-arrow-trending-up"
|
||||
/>
|
||||
<x-stat
|
||||
class="bg-slate-100 dark:bg-base-200"
|
||||
title="Total Cost Basis"
|
||||
value="22.124"
|
||||
icon="o-arrow-trending-up"
|
||||
/>
|
||||
<x-stat
|
||||
class="bg-slate-100 dark:bg-base-200"
|
||||
title="Total Market Value"
|
||||
value="22.124"
|
||||
icon="o-arrow-trending-up"
|
||||
/>
|
||||
<x-stat
|
||||
class="bg-slate-100 dark:bg-base-200"
|
||||
title="Realized Gain/Loss"
|
||||
value="22.124"
|
||||
icon="o-arrow-trending-up"
|
||||
/>
|
||||
<x-stat
|
||||
class="bg-slate-100 dark:bg-base-200"
|
||||
title="Dividends Earned"
|
||||
value="22.124"
|
||||
icon="o-arrow-trending-up"
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mt-6 grid md:grid-cols-7 gap-5">
|
||||
|
||||
<x-ib-card title="All portfolio holdings" 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>
|
||||
|
||||
<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">
|
||||
|
||||
@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="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>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
<x-app-layout>
|
||||
<div>
|
||||
|
||||
<x-ib-toolbar title="Create Portfolio" />
|
||||
|
||||
@livewire('manage-portfolio-form', ['submit' => 'save'])
|
||||
</div>
|
||||
</x-app-layout>
|
||||
@@ -0,0 +1,227 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Portfolio;
|
||||
use Livewire\Attributes\{Title, Rule};
|
||||
use Livewire\Volt\Component;
|
||||
|
||||
new class extends Component {
|
||||
|
||||
public bool $showDrawer2 = false;
|
||||
public $scope = 'YTD';
|
||||
|
||||
public function changeScope ($scope)
|
||||
{
|
||||
$this->scope = $scope;
|
||||
}
|
||||
|
||||
public function getScopeName ($scope)
|
||||
{
|
||||
return collect($this->options)->where('id', $scope)['name'];
|
||||
}
|
||||
|
||||
public $options = [
|
||||
['id' => '1M', 'name' => '1 month'],
|
||||
['id' => '3M', 'name' => '3 months'],
|
||||
['id' => 'YTD', 'name' => 'Year to date'],
|
||||
['id' => '1Y', 'name' => '1 year'],
|
||||
['id' => '3Y', 'name' => '3 years'],
|
||||
['id' => 'ALL', 'name' => 'All time']
|
||||
];
|
||||
|
||||
public ?Portfolio $portfolio;
|
||||
|
||||
private function generateDateSeries($startDate, $endDate) {
|
||||
$dateArray = [];
|
||||
$currentDate = strtotime($startDate);
|
||||
$endDate = strtotime($endDate);
|
||||
|
||||
while ($currentDate <= $endDate) {
|
||||
// Generate a random integer
|
||||
$randomInt = rand(1000, 3000);
|
||||
|
||||
// Format the current date to 'Y-m-d'
|
||||
$formattedDate = date('Y-m-d', $currentDate);
|
||||
|
||||
// Append the date and random integer to the array
|
||||
$dateArray[] = [$formattedDate, $randomInt];
|
||||
|
||||
// Move to the next day
|
||||
$currentDate = strtotime("+1 day", $currentDate);
|
||||
}
|
||||
|
||||
return $dateArray;
|
||||
}
|
||||
|
||||
public array $myChart;
|
||||
|
||||
public function mount() {
|
||||
|
||||
$this->myChart = [
|
||||
'series' => [
|
||||
[
|
||||
'name' => 'Total Views',
|
||||
'data' => $this->generateDateSeries('2024-01-01', '2024-08-01')
|
||||
],
|
||||
[
|
||||
'name' => 'Second Views',
|
||||
'data' => $this->generateDateSeries('2024-01-01', '2024-08-01')
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<x-app-layout>
|
||||
<div >
|
||||
|
||||
|
||||
|
||||
<x-ib-drawer
|
||||
key="manage-portfolio"
|
||||
title="{{ $portfolio->title }}"
|
||||
>
|
||||
|
||||
@livewire('manage-portfolio-form', ['portfolio' => $portfolio, 'submit' => "update", 'hideCancel' => true])
|
||||
|
||||
</x-ib-drawer>
|
||||
|
||||
<x-ib-toolbar :title="$portfolio->title">
|
||||
|
||||
@if($portfolio->wishlist)
|
||||
<x-badge value="Wishlist" class="badge-primary mr-3" />
|
||||
@endif
|
||||
|
||||
<x-button
|
||||
title="Edit Portfolio"
|
||||
icon="o-pencil"
|
||||
class="btn-circle btn-ghost btn-sm text-secondary"
|
||||
@click="$dispatch('toggle-manage-portfolio')"
|
||||
/>
|
||||
</x-ib-toolbar>
|
||||
|
||||
<x-card class="bg-slate-100 dark:bg-base-200 rounded-lg mb-6">
|
||||
|
||||
<div class="flex justify-between items-center mb-2">
|
||||
|
||||
<div class="flex items-center">
|
||||
|
||||
<h2 class="text-xl mr-4">Performance</h2>
|
||||
<div id="chart-legend-portfolio-{{ $portfolio->id }}" class="flex space-around"></div>
|
||||
|
||||
</div>
|
||||
{{-- {{ $scope }} --}}
|
||||
<x-dropdown label="YTD" class="btn-ghost btn-sm" >
|
||||
|
||||
<x-menu >
|
||||
{{-- @foreach($options as $option)
|
||||
|
||||
<x-menu-item
|
||||
title="{{ $option['name'] }}"
|
||||
x-on:click="$wire.changeScope('{{ $option['id'] }}')"
|
||||
/>
|
||||
|
||||
@endforeach --}}
|
||||
</x-menu>
|
||||
</x-dropdown>
|
||||
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="h-[280px] mb-5"
|
||||
|
||||
>
|
||||
{{-- <x-ib-apex-chart :series-data="$myChart" :key="Str::uuid()" name="portfolio-{{ $portfolio->id }}" /> --}}
|
||||
</div>
|
||||
|
||||
</x-card>
|
||||
|
||||
<div class="grid md:grid-cols-5 gap-5">
|
||||
<x-stat
|
||||
class="bg-slate-100 dark:bg-base-200"
|
||||
title="Market Gain/Loss"
|
||||
value="22.124"
|
||||
icon="o-arrow-trending-up"
|
||||
/>
|
||||
<x-stat
|
||||
class="bg-slate-100 dark:bg-base-200"
|
||||
title="Total Cost Basis"
|
||||
value="22.124"
|
||||
icon="o-arrow-trending-up"
|
||||
/>
|
||||
<x-stat
|
||||
class="bg-slate-100 dark:bg-base-200"
|
||||
title="Total Market Value"
|
||||
value="22.124"
|
||||
icon="o-arrow-trending-up"
|
||||
/>
|
||||
<x-stat
|
||||
class="bg-slate-100 dark:bg-base-200"
|
||||
title="Realized Gain/Loss"
|
||||
value="22.124"
|
||||
icon="o-arrow-trending-up"
|
||||
/>
|
||||
<x-stat
|
||||
class="bg-slate-100 dark:bg-base-200"
|
||||
title="Dividends Earned"
|
||||
value="22.124"
|
||||
icon="o-arrow-trending-up"
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mt-6 grid md:grid-cols-7 gap-5">
|
||||
|
||||
<x-ib-card title="All portfolio holdings" 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>
|
||||
|
||||
<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">
|
||||
|
||||
@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="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>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</x-app-layout>
|
||||
+3
-2
@@ -2,6 +2,7 @@
|
||||
|
||||
use Livewire\Volt\Volt;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\PortfolioController;
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
@@ -11,7 +12,7 @@ Route::middleware(['auth:sanctum', config('jetstream.auth_session'), 'verified']
|
||||
|
||||
Volt::route('/dashboard', 'dashboard')->name('dashboard');
|
||||
|
||||
Volt::route('/portfolio/create', 'portfolio.create')->name('portfolio.create');
|
||||
Volt::route('/portfolio/{portfolio}', 'portfolio.show')->name('portfolio.show');
|
||||
Route::get('/portfolio/create', [PortfolioController::class, 'create'])->name('portfolio.create');
|
||||
Route::get('/portfolio/{portfolio}', [PortfolioController::class, 'show'])->name('portfolio.show');
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user