From 982965b8fdb793b7bd692b271e8c093a11c70ae0 Mon Sep 17 00:00:00 2001 From: moseuh Date: Thu, 27 Jun 2024 22:53:46 +0300 Subject: [PATCH] changes on ui and models --- .../Admin/Resources/CartItemResource.php | 14 +--- .../GroupResource/Pages/EditGroup.php | 4 +- .../Admin/Resources/InvoiceResource.php | 74 ++++++++----------- resources/views/invoices/show.blade.php | 14 ++-- 4 files changed, 45 insertions(+), 61 deletions(-) diff --git a/app/Filament/Admin/Resources/CartItemResource.php b/app/Filament/Admin/Resources/CartItemResource.php index 38e30da..aff9068 100644 --- a/app/Filament/Admin/Resources/CartItemResource.php +++ b/app/Filament/Admin/Resources/CartItemResource.php @@ -2,23 +2,19 @@ namespace App\Filament\Admin\Resources; -use Filament\Forms; -use Filament\Tables; use App\Models\CartItem; +use Filament\Forms; use Filament\Forms\Form; +use Filament\Tables; use Filament\Tables\Table; use Filament\Resources\Resource; use Filament\Tables\Columns\TextColumn; -use Illuminate\Database\Eloquent\Builder; use Filament\Forms\Components\BelongsToSelect; -use Illuminate\Database\Eloquent\SoftDeletingScope; use App\Filament\Admin\Resources\CartItemResource\Pages; -use App\Filament\Admin\Resources\CartItemResource\RelationManagers; class CartItemResource extends Resource { protected static ?string $model = CartItem::class; - protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; public static function form(Form $form): Form @@ -28,7 +24,6 @@ public static function form(Form $form): Form BelongsToSelect::make('user_id') ->relationship('user', 'name') ->required(), - BelongsToSelect::make('product_id') ->relationship('product', 'name') ->required(), @@ -38,7 +33,6 @@ public static function form(Form $form): Form Forms\Components\TextInput::make('price') ->numeric() ->prefix('GBP') - ]); } @@ -60,7 +54,7 @@ public static function table(Table $table): Table TextColumn::make('price') ]) ->filters([ - // + // Define filters here if needed ]) ->actions([ Tables\Actions\EditAction::make(), @@ -75,7 +69,7 @@ public static function table(Table $table): Table public static function getRelations(): array { return [ - // + // Define relations here if needed ]; } diff --git a/app/Filament/Admin/Resources/GroupResource/Pages/EditGroup.php b/app/Filament/Admin/Resources/GroupResource/Pages/EditGroup.php index 34ceaa8..27ab209 100644 --- a/app/Filament/Admin/Resources/GroupResource/Pages/EditGroup.php +++ b/app/Filament/Admin/Resources/GroupResource/Pages/EditGroup.php @@ -3,7 +3,7 @@ namespace App\Filament\Admin\Resources\GroupResource\Pages; use App\Filament\Admin\Resources\GroupResource; -use Filament\Actions; +use Filament\Actions\DeleteAction; use Filament\Resources\Pages\EditRecord; class EditGroup extends EditRecord @@ -13,7 +13,7 @@ class EditGroup extends EditRecord protected function getHeaderActions(): array { return [ - Actions\DeleteAction::make(), + DeleteAction::make(), ]; } } diff --git a/app/Filament/Admin/Resources/InvoiceResource.php b/app/Filament/Admin/Resources/InvoiceResource.php index 29ca2d4..8f5edf0 100644 --- a/app/Filament/Admin/Resources/InvoiceResource.php +++ b/app/Filament/Admin/Resources/InvoiceResource.php @@ -2,65 +2,55 @@ namespace App\Filament\Admin\Resources; -use Filament\Forms; -use Filament\Tables; use App\Models\Order; use App\Models\Invoice; use App\Models\Customer; +use Filament\Forms; use Filament\Forms\Form; +use Filament\Tables; use Filament\Tables\Table; use Filament\Resources\Resource; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\SoftDeletingScope; use App\Filament\Admin\Resources\InvoiceResource\Pages; -use App\Filament\Admin\Resources\InvoiceResource\RelationManagers; class InvoiceResource extends Resource { protected static ?string $model = Invoice::class; - protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; public static function form(Form $form): Form { - return $form - ->schema([ - Forms\Components\Select::make('customer_id') - ->label('Customer') - ->required() - ->options(Customer::pluck('name', 'id')) - ->reactive(), - - Forms\Components\Select::make('order_id') - ->label('Order') - ->required() - ->options(Order::pluck('id', 'id')) - ->reactive(), - - Forms\Components\DatePicker::make('invoice_date') - ->label('Invoice Date') - ->required(), - - Forms\Components\TextInput::make('total_amount') - ->label('Total Amount') - ->required() - ->numeric(), - - Forms\Components\Select::make('payment_status') - ->label('Payment Status') - ->required() - ->options([ - 'pending' => 'Pending', - 'paid' => 'Paid', - 'cancelled' => 'Cancelled', - ]), - ]); + return $form->schema([ + Forms\Components\Select::make('customer_id') + ->label('Customer') + ->required() + ->options(Customer::pluck('name', 'id')) + ->reactive(), + Forms\Components\Select::make('order_id') + ->label('Order') + ->required() + ->options(Order::pluck('id', 'id')) + ->reactive(), + Forms\Components\DatePicker::make('invoice_date') + ->label('Invoice Date') + ->required(), + Forms\Components\TextInput::make('total_amount') + ->label('Total Amount') + ->required() + ->numeric(), + Forms\Components\Select::make('payment_status') + ->label('Payment Status') + ->required() + ->options([ + 'pending' => 'Pending', + 'paid' => 'Paid', + 'cancelled' => 'Cancelled', + ]), + ]); } public static function table(Table $table): Table { - return $table - ->columns([ + return $table->columns([ Tables\Columns\TextColumn::make('customer.name') ->label('Customer'), Tables\Columns\TextColumn::make('order.id') @@ -73,7 +63,7 @@ public static function table(Table $table): Table ->label('Payment Status'), ]) ->filters([ - // + // Define filters here if needed ]) ->actions([ Tables\Actions\EditAction::make(), @@ -88,7 +78,7 @@ public static function table(Table $table): Table public static function getRelations(): array { return [ - // + // Define relations here if needed ]; } diff --git a/resources/views/invoices/show.blade.php b/resources/views/invoices/show.blade.php index 25edd2a..db99532 100644 --- a/resources/views/invoices/show.blade.php +++ b/resources/views/invoices/show.blade.php @@ -2,18 +2,18 @@ @section('content')
-

Invoice Details

-
+

Invoice Details

+

Invoice ID: {{ $invoice->id }}

Invoice Date: {{ $invoice->invoice_date->format('Y-m-d') }}

Total Amount: ${{ number_format($invoice->total_amount, 2) }}

-

Customer Information

+

Customer Information

Name: {{ $invoice->customer->name }}

Email: {{ $invoice->customer->email }}

-

Products

- - +

Products

+
+ @@ -38,6 +38,6 @@
Product Name Quantity
- Back to Invoices + Back to Invoices
@endsection