*/ public function rules(): array { $invitation = UserInvitation::where('token', $this->route('token'))->first(); $userExists = $invitation && User::where('email', $invitation->email)->exists(); return [ 'name' => [$userExists ? 'nullable' : 'required', 'string', 'max:255'], 'password' => [$userExists ? 'nullable' : 'required', 'string', 'min:8', 'confirmed'], ]; } }