diff --git a/app/Http/Controllers/PortfolioController.php b/app/Http/Controllers/PortfolioController.php index 79e3229..16483a2 100644 --- a/app/Http/Controllers/PortfolioController.php +++ b/app/Http/Controllers/PortfolioController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers; use App\Models\Portfolio; -use Illuminate\Http\Request; class PortfolioController extends Controller { @@ -23,5 +22,4 @@ class PortfolioController extends Controller { return view('portfolio.show', compact('portfolio')); } - } diff --git a/resources/views/components/confirmation-modal.blade.php b/resources/views/components/confirmation-modal.blade.php index c26b430..95f7fc6 100644 --- a/resources/views/components/confirmation-modal.blade.php +++ b/resources/views/components/confirmation-modal.blade.php @@ -1,7 +1,7 @@ @props(['id' => null, 'maxWidth' => null]) -
+
@@ -21,7 +21,9 @@
-
+
{{ $footer }}
+ + diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php new file mode 100644 index 0000000..0820ae9 --- /dev/null +++ b/resources/views/dashboard.blade.php @@ -0,0 +1,97 @@ + + + + + @livewire('portfolio-performance-chart', [ + 'name' => 'dashboard' + ]) + + + +
+ + + + + + +
+ +
+ + + + @php + $users = App\Models\User::take(3)->get(); + @endphp + + @foreach($users as $user) + + @endforeach + + + + + + @php + $users = App\Models\User::take(3)->get(); + @endphp + + @foreach($users as $user) + + @endforeach + + + + + + @php + $users = App\Models\User::take(3)->get(); + @endphp + + @foreach($users as $user) + + @endforeach + + + + + + @php + $users = App\Models\User::take(3)->get(); + @endphp + + @foreach($users as $user) + + @endforeach + + + +
+ +
\ No newline at end of file diff --git a/resources/views/livewire/dashboard.blade.php b/resources/views/livewire/dashboard.blade.php deleted file mode 100644 index 1c4ecc7..0000000 --- a/resources/views/livewire/dashboard.blade.php +++ /dev/null @@ -1,205 +0,0 @@ -scope = $scope; - } - - public function getScopeName ($scope) - { - return collect($this->options)->where('id', $scope)['name']; - } - - public $options = [ - ['id' => '1M', 'name' => '1 month'], - ['id' => '2M', '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') - ], - ], - - ]; - - } - - -}; ?> - -
- - - - - -
- -
- -

Performance

-
- -
- - - - - @foreach($options as $option) - - - - @endforeach - - - -
- -
- -
- - -
- -
- - - - - - -
- -
- - - - @php - $users = App\Models\User::take(3)->get(); - @endphp - - @foreach($users as $user) - - @endforeach - - - - - - @php - $users = App\Models\User::take(3)->get(); - @endphp - - @foreach($users as $user) - - @endforeach - - - - - - @php - $users = App\Models\User::take(3)->get(); - @endphp - - @foreach($users as $user) - - @endforeach - - - - - - @php - $users = App\Models\User::take(3)->get(); - @endphp - - @foreach($users as $user) - - @endforeach - - - -
- -
\ No newline at end of file diff --git a/resources/views/livewire/manage-portfolio-form.blade.php b/resources/views/livewire/manage-portfolio-form.blade.php index f539928..69a63cb 100644 --- a/resources/views/livewire/manage-portfolio-form.blade.php +++ b/resources/views/livewire/manage-portfolio-form.blade.php @@ -9,20 +9,24 @@ use Mary\Traits\Toast; new class extends Component { use Toast; - public string $submit; + // props public ?Portfolio $portfolio; public Bool $hideCancel = false; #[Rule('required|min:5')] - public string $title; + public String $title; #[Rule('sometimes|nullable')] - public ?string $notes; + public ?String $notes; - #[Rule('sometimes|boolean')] - public ?bool $wishlist; + #[Rule('sometimes|nullable|boolean')] + public Bool $wishlist = false; - public function mount() { + public Bool $confirmingPortfolioDeletion = false; + + // methods + public function mount() + { if (isset($this->portfolio)) { @@ -32,11 +36,6 @@ new class extends Component { } } - public function categories(): Collection - { - return Category::all(); - } - public function update() { $this->portfolio->update($this->validate()); @@ -69,29 +68,57 @@ new class extends Component { $this->success('Portfolio created', redirectTo: "/portfolio/{$portfolio->id}"); } - public function with(): array + public function delete() { - return [ - // 'categories' => $this->categories() - ]; + + $this->portfolio->delete(); + + $this->success('Portfolio deleted', redirectTo: "/dashboard"); } }; ?>
- + - {{-- --}} - - @if (!$hideCancel) - + @if ($portfolio) + @endif - + + @if (!$hideCancel) + + @endif + + + + + {{ __('Delete Portfolio') }} + + + + {{ __('Are you sure you want to delete this portfolio? Once a portfolio is deleted, all of its holdings and other data will be permanently deleted.') }} + + + + + {{ __('Cancel') }} + + + + {{ __('Delete Portfolio') }} + + +
\ No newline at end of file diff --git a/resources/views/livewire/portfolio-performance-card.blade.php b/resources/views/livewire/portfolio-performance-card.blade.php new file mode 100644 index 0000000..5013d0a --- /dev/null +++ b/resources/views/livewire/portfolio-performance-card.blade.php @@ -0,0 +1,44 @@ + '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'] + ]; + + protected $listeners = ['data-scope-updated' => 'test']; + + public function test() + { + $this->value = 148; + } + + // methods + public function mount() + { + // + + } + +}; ?> + + diff --git a/resources/views/livewire/portfolio-performance-chart.blade.php b/resources/views/livewire/portfolio-performance-chart.blade.php new file mode 100644 index 0000000..59f271b --- /dev/null +++ b/resources/views/livewire/portfolio-performance-chart.blade.php @@ -0,0 +1,112 @@ + '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'] + ]; + + // data + public Array $myChart; + + // methods + 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') + ], + ], + + ]; + } + + public function changeScope($scope) + { + $this->scope = $scope; + + $this->dispatch('data-scope-updated', $scope); + } + + public function getScopeName($scope) + { + return collect($this->options)->where('id', $scope)['name']; + } + + 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; + } + +}; ?> + +
+
+ +
+ +

{{ __('Performance') }}

+
+ +
+ + + + + @foreach($options as $option) + + + + @endforeach + + + +
+ +
+ +
+ +
diff --git a/resources/views/portfolio/create.blade.php b/resources/views/portfolio/create.blade.php index e47ac9b..7d41a0f 100644 --- a/resources/views/portfolio/create.blade.php +++ b/resources/views/portfolio/create.blade.php @@ -3,6 +3,6 @@ - @livewire('manage-portfolio-form', ['submit' => 'save']) + @livewire('manage-portfolio-form')
diff --git a/resources/views/portfolio/show.blade.php b/resources/views/portfolio/show.blade.php index 41219ff..56e018c 100644 --- a/resources/views/portfolio/show.blade.php +++ b/resources/views/portfolio/show.blade.php @@ -1,78 +1,3 @@ -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') - ], - ], - - ]; - - } -}; ?> -
@@ -81,18 +6,21 @@ new class extends Component { title="{{ $portfolio->title }}" > - @livewire('manage-portfolio-form', ['portfolio' => $portfolio, 'submit' => "update", 'hideCancel' => true]) + @livewire('manage-portfolio-form', [ + 'portfolio' => $portfolio, + 'hideCancel' => true + ]) @if($portfolio->wishlist) - + @endif -
- -
- -

Performance

-
- -
-{{-- {{ $scope }} --}} - - - - {{-- @foreach($options as $option) - - - - @endforeach --}} - - - -
- -
- {{-- --}} -
+ @livewire('portfolio-performance-chart', [ + 'name' => 'portfolio-'.$portfolio->id, + 'portfolio' => $portfolio + ])
- + /> --}} group(function () { - Volt::route('/dashboard', 'dashboard')->name('dashboard'); + Route::view('/dashboard', 'dashboard')->name('dashboard'); Route::get('/portfolio/create', [PortfolioController::class, 'create'])->name('portfolio.create'); Route::get('/portfolio/{portfolio}', [PortfolioController::class, 'show'])->name('portfolio.show');