|string> */ public function rules(): array { $currentYear = date('Y'); return [ 'vintage' => ['required', 'integer', 'min:1900', 'max:' . ($currentYear + 1)], 'grape_variety_id' => ['required', 'exists:grape_varieties,id'], 'wine_name' => ['required', 'string', 'max:255'], 'wine_type' => ['nullable', 'in:red,white,rose'], 'description' => ['nullable', 'string'], 'alcohol_percentage' => ['nullable', 'numeric', 'min:0', 'max:20'], 'bottles_produced' => ['required', 'integer', 'min:0'], 'bottles_in_stock' => ['required', 'integer', 'min:0', 'lte:bottles_produced'], 'price_per_bottle' => ['nullable', 'numeric', 'min:0'], 'bottle_volume' => ['nullable', 'numeric', 'min:0', 'max:10'], 'production_date' => ['nullable', 'date', 'before_or_equal:today'], 'bottling_date' => ['nullable', 'date', 'before_or_equal:today', 'after_or_equal:production_date'], 'status' => ['required', 'in:in_production,aging,ready,sold_out'], 'image_url' => ['nullable', 'url', 'max:500'], ]; } /** * Get custom messages for validator errors. * * @return array */ public function messages(): array { return [ 'bottles_in_stock.lte' => 'Bottles in stock cannot exceed bottles produced.', 'bottling_date.after_or_equal' => 'Bottling date must be after or equal to production date.', ]; } /** * Get custom attribute names for validator errors. * * @return array */ public function attributes(): array { return [ 'grape_variety_id' => 'grape variety', 'wine_name' => 'wine name', 'wine_type' => 'wine type', 'alcohol_percentage' => 'alcohol percentage', 'bottles_produced' => 'bottles produced', 'bottles_in_stock' => 'bottles in stock', 'price_per_bottle' => 'price per bottle', 'bottle_volume' => 'bottle volume', 'production_date' => 'production date', 'bottling_date' => 'bottling date', 'image_url' => 'image URL', ]; } }