'required|string|max:20|unique:customers,customer_code', 'name' => 'required|string|max:100', 'address' => 'required|string', 'branch_code' => 'required|string|max:3|exists:branches,code', 'date_of_birth' => 'nullable|date', 'email' => 'nullable|string|max:100|email', ]; if ($this->method() == 'PUT') { $rules['customer_code'] = 'required|string|max:20|unique:customers,customer_code,' . $this->id; } return $rules; } public function authorize() : bool { return true; } }