|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') && $this->filled('tsn_number_description')) { \App\Models\PricingCode::createOrUpdate( \App\Models\PricingCode::TYPE_TSN_NUMBER, $this->input('tsn_number'), $this->input('tsn_number_description') ); } // Сохраняем расшифровку шифра расценки в справочник, если указана if ($this->filled('pricing_code') && $this->filled('pricing_code_description')) { \App\Models\PricingCode::createOrUpdate( \App\Models\PricingCode::TYPE_PRICING_CODE, $this->input('pricing_code'), $this->input('pricing_code_description') ); } } }