Files
twotalesanimation 6de01c13c5 New Initial Commit
2025-12-09 12:04:54 +02:00

48 lines
1.6 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Filament\Resources\OrderResource\Widgets;
use Filament\Tables;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;
use Illuminate\Database\Eloquent\Model;
class OrderItemsTable extends BaseWidget
{
public ?Model $record = null;
protected static ?string $heading = 'Order Items';
public function table(Table $table): Table
{
return $table
->query(
fn () => $this->record->items()->getQuery()
)
->columns([
Tables\Columns\TextColumn::make('product.name')
->label('Product'),
Tables\Columns\TextColumn::make('printStock.name')
->label('Print Stock')
->default('N/A'),
Tables\Columns\TextColumn::make('type')
->badge(),
Tables\Columns\TextColumn::make('specifications')
->label('Specifications')
->getStateUsing(function ($record) {
if ($record->type === 'wallpaper') {
return "Length: {$record->length}m";
} elseif ($record->type === 'mural') {
$area = number_format($record->width * $record->height, 2);
return "{$record->width}m × {$record->height}m ({$area}m²)";
}
return 'N/A';
}),
Tables\Columns\TextColumn::make('price')
->money('ZAR')
->alignEnd(),
])
->paginated(false);
}
}