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); } }