<?php
 namespace App\Http\Requests\Admin; use Illuminate\Foundation\Http\FormRequest; class ProductCustomFieldOrderRequest extends FormRequest { public function authorize(): bool { $product = $this->route('product'); return $this->user()->can('update', $product); } public function rules(): array { return [ 'fields' => 'required|array', 'fields.*.id' => 'required|integer|exists:product_custom_fields,id', 'fields.*.order' => 'required|integer|min:0', ]; } public function messages(): array { return [ 'fields.required' => __('admin/products.custom_fields.validation.fields.required'), 'fields.array' => __('admin/products.custom_fields.validation.fields.array'), 'fields.*.id.required' => __('admin/products.custom_fields.validation.field_id.required'), 'fields.*.id.integer' => __('admin/products.custom_fields.validation.field_id.integer'), 'fields.*.id.exists' => __('admin/products.custom_fields.validation.field_id.exists'), 'fields.*.order.required' => __('admin/products.custom_fields.validation.field_order.required'), 'fields.*.order.integer' => __('admin/products.custom_fields.validation.field_order.integer'), 'fields.*.order.min' => __('admin/products.custom_fields.validation.field_order.min'), ]; } } 