Skip to content

Commit

Permalink
changes on ui and models
Browse files Browse the repository at this point in the history
  • Loading branch information
moseuh committed Jun 27, 2024
1 parent d33c228 commit 982965b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 61 deletions.
14 changes: 4 additions & 10 deletions app/Filament/Admin/Resources/CartItemResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(),
Expand All @@ -38,7 +33,6 @@ public static function form(Form $form): Form
Forms\Components\TextInput::make('price')
->numeric()
->prefix('GBP')

]);
}

Expand All @@ -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(),
Expand All @@ -75,7 +69,7 @@ public static function table(Table $table): Table
public static function getRelations(): array
{
return [
//
// Define relations here if needed
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -13,7 +13,7 @@ class EditGroup extends EditRecord
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
DeleteAction::make(),
];
}
}
74 changes: 32 additions & 42 deletions app/Filament/Admin/Resources/InvoiceResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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(),
Expand All @@ -88,7 +78,7 @@ public static function table(Table $table): Table
public static function getRelations(): array
{
return [
//
// Define relations here if needed
];
}

Expand Down
14 changes: 7 additions & 7 deletions resources/views/invoices/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

@section('content')
<div class="container">
<h2>Invoice Details</h2>
<div class="invoice-info">
<h2 class="mb-4">Invoice Details</h2>
<div class="invoice-info mb-4">
<p><strong>Invoice ID:</strong> {{ $invoice->id }}</p>
<p><strong>Invoice Date:</strong> {{ $invoice->invoice_date->format('Y-m-d') }}</p>
<p><strong>Total Amount:</strong> ${{ number_format($invoice->total_amount, 2) }}</p>
<h3>Customer Information</h3>
<h3 class="mt-4">Customer Information</h3>
<p><strong>Name:</strong> {{ $invoice->customer->name }}</p>
<p><strong>Email:</strong> {{ $invoice->customer->email }}</p>
</div>
<h3>Products</h3>
<table class="table">
<thead>
<h3 class="mb-4">Products</h3>
<table class="table table-bordered">
<thead class="thead-light">
<tr>
<th>Product Name</th>
<th>Quantity</th>
Expand All @@ -38,6 +38,6 @@
</tr>
</tfoot>
</table>
<a href="{{ route('invoices.index') }}" class="btn btn-primary">Back to Invoices</a>
<a href="{{ route('invoices.index') }}" class="btn btn-primary mt-4">Back to Invoices</a>
</div>
@endsection

0 comments on commit 982965b

Please sign in to comment.