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
110 lines
4.0 KiB
PHP
110 lines
4.0 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\CountryResource\Pages;
|
|
use App\Models\Country;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Form;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
|
|
class CountryResource extends Resource
|
|
{
|
|
protected static ?string $model = Country::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-globe-alt';
|
|
|
|
protected static ?string $navigationLabel = 'کشورها';
|
|
protected static ?string $navigationGroup = 'تنظیمات';
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Forms\Components\TextInput::make('name')
|
|
->required()
|
|
->maxLength(255)
|
|
->label('Country Name'),
|
|
Forms\Components\TextInput::make('iso_code')
|
|
->required()
|
|
->maxLength(2)
|
|
->unique(ignoreRecord: true)
|
|
->label('ISO Code'),
|
|
Forms\Components\Grid::make()
|
|
->schema([
|
|
Forms\Components\TextInput::make('export_zone_parcel')
|
|
->required()
|
|
->numeric()
|
|
->minValue(1)
|
|
->maxValue(10)
|
|
->label('Export Zone (Parcel)'),
|
|
Forms\Components\TextInput::make('export_zone_doc')
|
|
->required()
|
|
->numeric()
|
|
->minValue(1)
|
|
->maxValue(10)
|
|
->label('Export Zone (Doc)'),
|
|
Forms\Components\TextInput::make('import_zone_parcel')
|
|
->required()
|
|
->numeric()
|
|
->minValue(1)
|
|
->maxValue(10)
|
|
->label('Import Zone (Parcel)'),
|
|
Forms\Components\TextInput::make('import_zone_doc')
|
|
->required()
|
|
->numeric()
|
|
->minValue(1)
|
|
->maxValue(10)
|
|
->label('Import Zone (Doc)'),
|
|
])
|
|
->columns(4),
|
|
Forms\Components\Toggle::make('is_active')
|
|
->label('Active')
|
|
->default(true),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('name')->searchable()->sortable()->label('Country'),
|
|
Tables\Columns\TextColumn::make('iso_code')->searchable()->sortable()->label('ISO'),
|
|
Tables\Columns\TextColumn::make('export_zone_parcel')->label('Export Parcel'),
|
|
Tables\Columns\TextColumn::make('export_zone_doc')->label('Export Doc'),
|
|
Tables\Columns\TextColumn::make('import_zone_parcel')->label('Import Parcel'),
|
|
Tables\Columns\TextColumn::make('import_zone_doc')->label('Import Doc'),
|
|
Tables\Columns\IconColumn::make('is_active')->boolean()->label('Active'),
|
|
])
|
|
->filters([
|
|
Tables\Filters\TernaryFilter::make('is_active')->label('Active Status'),
|
|
])
|
|
->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\ListCountries::route('/'),
|
|
'create' => Pages\CreateCountry::route('/create'),
|
|
'edit' => Pages\EditCountry::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|