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