move to volt sfc

This commit is contained in:
hackerESQ
2024-08-01 20:44:41 -05:00
parent f0b66051bf
commit 395fa95eb5
6 changed files with 298 additions and 50 deletions
@@ -1,37 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\Portfolio;
class PortfolioController extends Controller
{
/**
* Display form to create specified resource.
*
* @param Portfolio $portfolio
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('livewire.portfolio.create');
}
/**
* Display the specified resource.
*
* @param Portfolio $portfolio
* @return \Illuminate\Http\Response
*/
public function show(Portfolio $portfolio)
{
// $this->authorize('view', $portfolio);
return view('livewire.portfolio.show', [
'portfolio' => $portfolio
]);
}
}
+160
View File
@@ -0,0 +1,160 @@
<?php
return [
/*
|---------------------------------------------------------------------------
| Class Namespace
|---------------------------------------------------------------------------
|
| This value sets the root class namespace for Livewire component classes in
| your application. This value will change where component auto-discovery
| finds components. It's also referenced by the file creation commands.
|
*/
'class_namespace' => 'App\\Livewire',
/*
|---------------------------------------------------------------------------
| View Path
|---------------------------------------------------------------------------
|
| This value is used to specify where Livewire component Blade templates are
| stored when running file creation commands like `artisan make:livewire`.
| It is also used if you choose to omit a component's render() method.
|
*/
'view_path' => resource_path('views/livewire'),
/*
|---------------------------------------------------------------------------
| Layout
|---------------------------------------------------------------------------
| The view that will be used as the layout when rendering a single component
| as an entire page via `Route::get('/post/create', CreatePost::class);`.
| In this case, the view returned by CreatePost will render into $slot.
|
*/
'layout' => 'layouts.app',
/*
|---------------------------------------------------------------------------
| Lazy Loading Placeholder
|---------------------------------------------------------------------------
| Livewire allows you to lazy load components that would otherwise slow down
| the initial page load. Every component can have a custom placeholder or
| you can define the default placeholder view for all components below.
|
*/
'lazy_placeholder' => null,
/*
|---------------------------------------------------------------------------
| Temporary File Uploads
|---------------------------------------------------------------------------
|
| Livewire handles file uploads by storing uploads in a temporary directory
| before the file is stored permanently. All file uploads are directed to
| a global endpoint for temporary storage. You may configure this below:
|
*/
'temporary_file_upload' => [
'disk' => null, // Example: 'local', 's3' | Default: 'default'
'rules' => null, // Example: ['file', 'mimes:png,jpg'] | Default: ['required', 'file', 'max:12288'] (12MB)
'directory' => null, // Example: 'tmp' | Default: 'livewire-tmp'
'middleware' => null, // Example: 'throttle:5,1' | Default: 'throttle:60,1'
'preview_mimes' => [ // Supported file types for temporary pre-signed file URLs...
'png', 'gif', 'bmp', 'svg', 'wav', 'mp4',
'mov', 'avi', 'wmv', 'mp3', 'm4a',
'jpg', 'jpeg', 'mpga', 'webp', 'wma',
],
'max_upload_time' => 5, // Max duration (in minutes) before an upload is invalidated...
'cleanup' => true, // Should cleanup temporary uploads older than 24 hrs...
],
/*
|---------------------------------------------------------------------------
| Render On Redirect
|---------------------------------------------------------------------------
|
| This value determines if Livewire will run a component's `render()` method
| after a redirect has been triggered using something like `redirect(...)`
| Setting this to true will render the view once more before redirecting
|
*/
'render_on_redirect' => false,
/*
|---------------------------------------------------------------------------
| Eloquent Model Binding
|---------------------------------------------------------------------------
|
| Previous versions of Livewire supported binding directly to eloquent model
| properties using wire:model by default. However, this behavior has been
| deemed too "magical" and has therefore been put under a feature flag.
|
*/
'legacy_model_binding' => false,
/*
|---------------------------------------------------------------------------
| Auto-inject Frontend Assets
|---------------------------------------------------------------------------
|
| By default, Livewire automatically injects its JavaScript and CSS into the
| <head> and <body> of pages containing Livewire components. By disabling
| this behavior, you need to use @livewireStyles and @livewireScripts.
|
*/
'inject_assets' => true,
/*
|---------------------------------------------------------------------------
| Navigate (SPA mode)
|---------------------------------------------------------------------------
|
| By adding `wire:navigate` to links in your Livewire application, Livewire
| will prevent the default link handling and instead request those pages
| via AJAX, creating an SPA-like effect. Configure this behavior here.
|
*/
'navigate' => [
'show_progress_bar' => true,
'progress_bar_color' => '#2299dd',
],
/*
|---------------------------------------------------------------------------
| HTML Morph Markers
|---------------------------------------------------------------------------
|
| Livewire intelligently "morphs" existing HTML into the newly rendered HTML
| after each update. To make this process more reliable, Livewire injects
| "markers" into the rendered Blade surrounding @if, @class & @foreach.
|
*/
'inject_morph_markers' => true,
/*
|---------------------------------------------------------------------------
| Pagination Theme
|---------------------------------------------------------------------------
|
| When enabling Livewire's pagination feature by using the `WithPagination`
| trait, Livewire will use Tailwind templates to render pagination views
| on the page. If you want Bootstrap CSS, you can specify: "bootstrap"
|
*/
'pagination_theme' => 'tailwind',
];
@@ -1,5 +1,16 @@
<x-app-layout>
<livewire:portfolio.manage-portfolio-form submit="save" />
<?php
</x-app-layout>
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>
<livewire:portfolio.manage-portfolio-form submit="save" />
</div>
@@ -1,8 +1,6 @@
<?php
use App\Models\Category;
use App\Models\Portfolio;
use App\Models\User;
use Illuminate\Support\Collection;
use Livewire\Attributes\Rule;
use Livewire\Volt\Component;
@@ -12,8 +10,8 @@ new class extends Component {
use Toast;
public string $submit;
public ?Portfolio $portfolio;
public Bool $hideCancel = false;
#[Rule('required|min:5')]
public string $title;
@@ -79,14 +77,16 @@ new class extends Component {
<div class="grid lg:grid-cols-4 gap-10">
<x-form wire:submit="{{ $submit }}" class="col-span-3">
<x-input label="Title" wire:model="title" />
<x-input label="Title" wire:model="title" required />
{{-- <x-select label="Category" wire:model="category_id" placeholder="Select a category" :options="$categories" /> --}}
<x-textarea label="Body" wire:model="notes" rows="5" />
<x-slot:actions>
@if (!$hideCancel)
<x-button label="Cancel" link="{{ url()->previous() }}" />
@endif
<x-button label="{{ $submit == 'save' ? 'Create' : 'Update' }}" type="submit" icon="o-paper-airplane" class="btn-primary" spinner="save" />
</x-slot:actions>
</x-form>
@@ -1,5 +1,110 @@
<x-app-layout>
<livewire:portfolio.manage-portfolio-form :portfolio="$portfolio" submit="update" />
<?php
</x-app-layout>
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>
<div class="p-8 bg-base-200 rounded-md ">
<div class="flex justify-between mb-8">
<h1 class="text-2xl font-medium">{{ $portfolio->title }} </h1>
<x-button
title="Edit Portfolio"
icon="o-cog-8-tooth"
class="btn-circle btn-ghost btn-sm"
wire:click="$toggle('showDrawer2')"
/>
</div>
<div class="grid md:grid-cols-4 gap-5">
<x-stat
title="Realized Gain/Loss ($)"
description="This month"
value="22.124"
icon="o-arrow-trending-up"
tooltip-bottom="There"
/>
<x-stat
title="Realized Gain/Loss (%)"
description="This month"
value="22.124"
icon="o-arrow-trending-up"
tooltip-bottom="There"
/>
<x-stat
title="Market Gain/Loss ($)"
description="This month"
value="22.124"
icon="o-arrow-trending-up"
tooltip-bottom="There"
/>
<x-stat
title="Market Gain/Loss (%)"
description="This month"
value="22.124"
icon="o-arrow-trending-up"
tooltip-bottom="There"
/>
<x-stat
title="Total Cost Basis ($)"
description="This month"
value="22.124"
icon="o-arrow-trending-up"
tooltip-bottom="There"
/>
<x-stat
title="Total Market Value ($)"
description="This month"
value="22.124"
icon="o-arrow-trending-up"
tooltip-bottom="There"
/>
<x-stat
title="Number of Transactions"
description="This month"
value="22.124"
icon="o-arrow-trending-up"
tooltip-bottom="There"
/>
<x-stat
title="Dividends Earned ($)"
description="This month"
value="22.124"
icon="o-arrow-trending-up"
tooltip-bottom="There"
/>
</div>
<div class="grid md:grid-cols-3 gap-5">
@php
$users = App\Models\User::take(3)->get();
@endphp
@foreach($users as $user)
<x-list-item :item="$user" link="/docs/installation" />
@endforeach
</div>
</div>
<x-drawer
title="{{ $portfolio->title }}"
wire:model="showDrawer2"
class="w-11/12 lg:w-1/3"
with-close-button
close-on-escape
right
>
<livewire:portfolio.manage-portfolio-form :portfolio="$portfolio" submit="update" hide-cancel />
</x-drawer>
</div>
+10 -1
View File
@@ -1,17 +1,26 @@
<?php
use Livewire\Volt\Volt;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PortfolioController;
use App\Livewire\ShowPortfolio;
Route::get('/', function () {
return view('welcome');
});
Route::middleware(['auth:sanctum', config('jetstream.auth_session'), 'verified'])->group(function () {
Route::get('/dashboard', function () {
return view('dashboard');
})->name('dashboard');
Route::resource('portfolio', PortfolioController::class)->only(['show', 'create']);
Volt::route('/portfolio/create', 'portfolio.create')->name('portfolio.create');
Volt::route('/portfolio/{portfolio}', 'portfolio.show')->name('portfolio.show');
// Route::get('portfolio/{portfolio}', ShowPortfolio::class)->name('portfolio.show');
// Route::get('portfolio', ShowPortfolio::class)->name('portfolio.create');
// Route::resource('portfolio', PortfolioController::class)->only(['show', 'create']);
});