Registration Page with custom Field

I added new Register Page to my Panel, and need a new Field for REFERENCE CODE INVITE.

 protected function getInviteCodeFormComponent(): Component
    {
        return Field::make('ref_code')
            ->label('Invite Code')
            ->helperText('Inout your invite code here.')
            ->exists(modifyRuleUsing: function (Exists $rule) {
                
                $rule->where(function ($query, $value) {
                    // Check if the Invite Code exists
                    $search_owner = User::where('ref_code', $value)
                        ->where('manager_level', 2)
                        ->first();
                    
                    if (!$search_owner) {
                        // If the invite code does not exist, show an error message
                        $query->fail('Invalid Manager Code.');
                    }
                    
                    // If the invite code exists, then add the "$search_owner->id" to your "affiliate_id" user registration.
                });
                
            });
}


But causing this error when send submit.
image.png
image.png
Was this page helpful?