New Initial Commit
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\PrintStockResource\Pages;
|
||||
use App\Models\PrintStock;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class PrintStockResource extends Resource
|
||||
{
|
||||
protected static ?string $model = PrintStock::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-cube';
|
||||
|
||||
protected static ?string $navigationLabel = 'Print Stocks';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\Textarea::make('description')
|
||||
->maxLength(65535)
|
||||
->columnSpanFull(),
|
||||
Forms\Components\TextInput::make('cost_per_meter')
|
||||
->required()
|
||||
->numeric()
|
||||
->prefix('R')
|
||||
->label('Cost per Meter'),
|
||||
Forms\Components\TextInput::make('cost_per_m2')
|
||||
->required()
|
||||
->numeric()
|
||||
->prefix('R')
|
||||
->label('Cost per m²'),
|
||||
Forms\Components\Select::make('type')
|
||||
->options([
|
||||
'wallpaper' => 'Wallpaper',
|
||||
'mural' => 'Mural',
|
||||
'both' => 'Both',
|
||||
])
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('width')
|
||||
->label('Width (meters)')
|
||||
->numeric()
|
||||
->step(0.01)
|
||||
->minValue(0.1)
|
||||
->default(1)
|
||||
->helperText('Width of wallpaper roll in meters'),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('cost_per_meter')
|
||||
->money('ZAR')
|
||||
->label('Cost/m')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('cost_per_m2')
|
||||
->money('ZAR')
|
||||
->label('Cost/m²')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('type')
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'wallpaper' => 'success',
|
||||
'mural' => 'info',
|
||||
'both' => 'warning',
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\SelectFilter::make('type')
|
||||
->options([
|
||||
'wallpaper' => 'Wallpaper',
|
||||
'mural' => 'Mural',
|
||||
'both' => 'Both',
|
||||
]),
|
||||
])
|
||||
->actions([
|
||||
//
|
||||
])
|
||||
->bulkActions([
|
||||
//
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ManagePrintStocks::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user