<?php
 namespace App\Http\Requests\Admin; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Rule; class DatacenterUpdateRequest extends FormRequest { public function authorize(): bool { $datacenter = $this->route('datacenter'); return $this->user()->can('update', $datacenter); } public function rules(): array { $datacenter = $this->route('datacenter'); return [ 'name' => 'required|string|max:255', 'code' => [ 'required', 'string', 'max:255', Rule::unique('datacenters', 'code')->ignore($datacenter), ], 'address' => 'nullable|string', 'city' => 'nullable|string|max:255', 'country_code' => 'nullable|string|size:2', 'notes' => 'nullable|string', ]; } public function messages(): array { return [ 'name.required' => __('admin/datacenters.validation_name_required'), 'code.required' => __('admin/datacenters.validation_code_required'), 'code.unique' => __('admin/datacenters.validation_code_unique'), 'country_code.size' => __('admin/datacenters.validation_country_code_size'), ]; } } 