<?php
 namespace App\Http\Requests\Admin; use Illuminate\Foundation\Http\FormRequest; class ProductGroupUpdateRequest extends FormRequest { public function authorize(): bool { $productGroup = $this->route('productGroup'); return $this->user()->can('update', $productGroup); } public function rules(): array { $productGroupId = $this->route('productGroup')->id ?? null; return [ 'name' => 'required|string|max:255|unique:product_groups,name,'.$productGroupId, 'description' => 'nullable|string', 'icon' => 'nullable|string', 'order' => 'required|integer|min:0', 'hidden' => 'nullable|boolean', 'gateways' => 'nullable|string', 'template' => 'nullable|string', 'is_active' => 'boolean', 'proration_enabled' => 'nullable|in:,0,1', 'billing_anchor_day' => 'nullable|integer|min:1|max:31', ]; } public function messages(): array { return [ 'name.required' => __('admin/product-groups.validation.name.required'), 'name.unique' => __('admin/product-groups.validation.name.unique'), 'order.required' => __('admin/product-groups.validation.order.required'), 'order.integer' => __('admin/product-groups.validation.order.integer'), 'order.min' => __('admin/product-groups.validation.order.min'), ]; } } 