|string> */ public function rules(): array { return [ 'article' => 'required|string|max:255', 'used_in_maf' => 'nullable|string|max:255', 'product_id' => 'nullable|exists:products,id', 'note' => 'nullable|string', 'purchase_price' => 'nullable|numeric|min:0', 'customer_price' => 'nullable|numeric|min:0', 'expertise_price' => 'nullable|numeric|min:0', 'tsn_number' => 'nullable|string|max:255', 'tsn_number_description' => 'nullable|string', 'pricing_code' => 'nullable|string', 'pricing_code_description' => 'nullable|string', 'min_stock' => 'nullable|integer|min:0', ]; } /** * Обработка данных после валидации */ protected function passedValidation() { // Сохраняем/обновляем расшифровку № по ТСН в справочник if ($this->filled('tsn_number')) { $description = $this->input('tsn_number_description'); // Сохраняем только если есть расшифровка if ($description) { \App\Models\PricingCode::createOrUpdate( \App\Models\PricingCode::TYPE_TSN_NUMBER, $this->input('tsn_number'), $description ); } } // Сохраняем/обновляем расшифровку шифра расценки в справочник if ($this->filled('pricing_code')) { $description = $this->input('pricing_code_description'); // Сохраняем только если есть расшифровка if ($description) { \App\Models\PricingCode::createOrUpdate( \App\Models\PricingCode::TYPE_PRICING_CODE, $this->input('pricing_code'), $description ); } } } }