'required|string|in:web,api', ]; if ($this->method() === 'PUT') { $rules['name'] = 'required|string|max:255|unique:roles,name,' . $this->id; } else { $rules['name'] = 'required|string|max:255'; } return $rules; } public function prepareForValidation() { $this->merge([ 'guard_names' => 'web', ]); } }