103 lines
3.3 KiB
PHP
103 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\ShippingRateResource\Pages;
|
|
use App\Models\ShippingRate;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Form;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
|
|
class ShippingRateResource extends Resource
|
|
{
|
|
protected static ?string $model = ShippingRate::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-currency-dollar';
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Forms\Components\Select::make('direction')
|
|
->options([
|
|
'import' => 'Import',
|
|
'export' => 'Export',
|
|
])
|
|
->required(),
|
|
Forms\Components\Select::make('type')
|
|
->options([
|
|
'DOCUMENT' => 'Document',
|
|
'NON DOC' => 'Non Document',
|
|
])
|
|
->required(),
|
|
Forms\Components\TextInput::make('weight')
|
|
->required()
|
|
->numeric()
|
|
->suffix('kg')
|
|
->label('Weight (kg)'),
|
|
|
|
// بخش زونها بر اساس فایل Import
|
|
Forms\Components\Section::make('Zone Prices')
|
|
->schema(array_map(fn ($i) =>
|
|
Forms\Components\TextInput::make("zone_{$i}")
|
|
->numeric()
|
|
->prefix('درهم')
|
|
->label("Zone {$i}")
|
|
->columnSpan(1),
|
|
range(1, 10)
|
|
))->columns(5),
|
|
])->columns(3);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('direction')
|
|
->badge()
|
|
->color(fn (string $state): string => $state === 'import' ? 'info' : 'success')
|
|
->searchable(),
|
|
Tables\Columns\TextColumn::make('type')
|
|
->badge()
|
|
->searchable(),
|
|
Tables\Columns\TextColumn::make('weight')
|
|
->numeric()
|
|
->sortable()
|
|
->suffix(' kg'),
|
|
Tables\Columns\TextColumn::make('zone_1')
|
|
->money('AED')
|
|
->label('Zone 1'),
|
|
])
|
|
->filters([
|
|
Tables\Filters\SelectFilter::make('direction'),
|
|
Tables\Filters\SelectFilter::make('type'),
|
|
])
|
|
->actions([
|
|
Tables\Actions\EditAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListShippingRates::route('/'),
|
|
'create' => Pages\CreateShippingRate::route('/create'),
|
|
'edit' => Pages\EditShippingRate::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|