ifnex/04_Laravel/app/Filament/Pages/PriceTestPage.php
Kazem Alghasi 0d04c89e91 refactor(admin): reorganize filament navigation and layout
Refactor the Filament admin panel structure by adjusting navigation sorting
across various resources to improve usability and logical grouping.

- Reorder navigation items in 'مالی' (Finance), 'تنظیمات' (Settings),
  and 'عملیات' (Operations) groups.
- Hide `PriceTestPage` from the main navigation sidebar.
- Adjust sidebar width and max content width in `AdminPanelProvider`.
- Add custom CSS asset for Filament styling.
2026-08-08 04:11:03 +03:30

87 lines
3.6 KiB
PHP

<?php
namespace App\Filament\Pages;
use App\Services\PriceCalculatorService;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Section;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Form;
use Filament\Pages\Page;
use App\Models\Country;
class PriceTestPage extends Page
{
use InteractsWithForms;
protected static ?string $navigationIcon = 'heroicon-o-calculator';
protected static string $view = 'filament.pages.price-test-page';
protected static ?string $navigationLabel = 'تست محاسبه قیمت';
protected static ?int $navigationSort = 999;
protected static bool $shouldRegisterNavigation = false;
public ?array $data = [];
public ?array $result = null;
public function mount(): void
{
$this->form->fill();
}
public function form(Form $form): Form
{
return $form
->schema([
Section::make('اطلاعات ارسال')
->schema([
Select::make('direction')
->label('جهت ارسال')
->options(['export' => 'صادرات (خروج از ایران)', 'import' => 'واردات (ورود به ایران)'])
->required()
->reactive()
->afterStateUpdated(fn ($state) => $this->result = null),
Select::make('type')
->label('نوع محموله')
->options(['DOCUMENT' => 'مدارک (DOCUMENT)', 'NON DOC' => 'غیر مدارک (NON DOC)'])
->required()
->afterStateUpdated(fn () => $this->result = null),
])->columns(2),
Section::make('مبدا و مقصد')
->schema([
Select::make('origin_country_id')
->label('کشور مبدا')
->options(Country::all()->pluck('name', 'id'))
->searchable()
->required()
->afterStateUpdated(fn () => $this->result = null),
Select::make('destination_country_id')
->label('کشور مقصد')
->options(Country::all()->pluck('name', 'id'))
->searchable()
->required()
->afterStateUpdated(fn () => $this->result = null),
])->columns(2),
Section::make('ابعاد و وزن')
->schema([
TextInput::make('weight')->label('وزن واقعی (کیلوگرم)')->numeric()->required()->afterStateUpdated(fn () => $this->result = null),
TextInput::make('length')->label('طول (سانتی‌متر)')->numeric()->required()->afterStateUpdated(fn () => $this->result = null),
TextInput::make('width')->label('عرض (سانتی‌متر)')->numeric()->required()->afterStateUpdated(fn () => $this->result = null),
TextInput::make('height')->label('ارتفاع (سانتی‌متر)')->numeric()->required()->afterStateUpdated(fn () => $this->result = null),
])->columns(4),
])
->statePath('data');
}
public function calculate()
{
$data = $this->form->getState();
$service = new PriceCalculatorService();
$this->result = $service->calculate($data);
}
}