ifnex/04_Laravel/app/Filament/Resources/ShippingRateResource.php
Kazem Alghasi 1c3811b01f feat(ui): localize filament admin panel and refactor settings page
Refactor the IfnexSettingsPage to use a custom Blade view and implement manual property binding for system settings. Additionally, localize navigation labels and groups to Persian for the Filament admin interface.

- Implement `ifnex-settings.blade.php` for custom settings management
- Localize navigation labels for Countries, Shipment Items, Shipments, and Shipping Rates
- Update navigation groups to Persian (تنظیمات, عملیات)
- Refactor `IfnexSettingsPage` to load settings from `SystemSetting` model during `mount`
- Fix type hinting for `ShipmentDirection` enum in `ShipmentResource` table columns
2026-08-04 04:44:24 +03:30

112 lines
4.7 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';
protected static ?string $navigationLabel = 'نرخ‌های حمل';
protected static ?string $navigationGroup = 'تنظیمات';
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('direction')
->options(['export' => 'Export', 'import' => 'Import'])
->required(),
Forms\Components\Select::make('type')
->options([
'DOC_NORMAL' => 'Doc Normal',
'DOC_ECONOMY' => 'Doc Economy',
'PARCEL' => 'Parcel',
])
->required(),
Forms\Components\TextInput::make('weight')
->required()
->numeric()
->suffix('kg')
->label('Weight (kg)'),
Forms\Components\Grid::make()
->schema([
Forms\Components\TextInput::make('zone_1')->numeric()->label('Zone 1'),
Forms\Components\TextInput::make('zone_2')->numeric()->label('Zone 2'),
Forms\Components\TextInput::make('zone_3')->numeric()->label('Zone 3'),
Forms\Components\TextInput::make('zone_4')->numeric()->label('Zone 4'),
Forms\Components\TextInput::make('zone_5')->numeric()->label('Zone 5'),
Forms\Components\TextInput::make('zone_6')->numeric()->label('Zone 6'),
Forms\Components\TextInput::make('zone_7')->numeric()->label('Zone 7'),
Forms\Components\TextInput::make('zone_8')->numeric()->label('Zone 8'),
Forms\Components\TextInput::make('zone_9')->numeric()->label('Zone 9'),
Forms\Components\TextInput::make('zone_10')->numeric()->label('Zone 10'),
])
->columns(5),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('direction')->badge()->label('Direction'),
Tables\Columns\TextColumn::make('type')->badge()->label('Type'),
Tables\Columns\TextColumn::make('weight')->numeric()->suffix(' kg')->label('Weight'),
Tables\Columns\TextColumn::make('zone_1')->label('Z1')->sortable(),
Tables\Columns\TextColumn::make('zone_2')->label('Z2')->sortable(),
Tables\Columns\TextColumn::make('zone_3')->label('Z3')->sortable(),
Tables\Columns\TextColumn::make('zone_4')->label('Z4')->sortable(),
Tables\Columns\TextColumn::make('zone_5')->label('Z5')->sortable(),
Tables\Columns\TextColumn::make('zone_6')->label('Z6')->sortable(),
Tables\Columns\TextColumn::make('zone_7')->label('Z7')->sortable(),
Tables\Columns\TextColumn::make('zone_8')->label('Z8')->sortable(),
Tables\Columns\TextColumn::make('zone_9')->label('Z9')->sortable(),
Tables\Columns\TextColumn::make('zone_10')->label('Z10')->sortable(),
])
->filters([
Tables\Filters\SelectFilter::make('direction')
->options(['export' => 'Export', 'import' => 'Import']),
Tables\Filters\SelectFilter::make('type')
->options([
'DOC_NORMAL' => 'Doc Normal',
'DOC_ECONOMY' => 'Doc Economy',
'PARCEL' => 'Parcel',
]),
])
->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'),
];
}
}