Unique validation rule ignored #2142
              
                Unanswered
              
          
                  
                    
                      paoloveggi
                    
                  
                
                  asked this question in
                Q&A
              
            Replies: 0 comments
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
Hello guys,
I have the following validation rules on a store context:
'code' => [ 'required', 'max:30', Rule::unique('mongodb.plico_user_groups', 'code')->where('company_id', 1) ]but the check for the unique key is ignored. I want to have a unique index based on the fields "code" and "company_id". If I try to insert twice the same "code" for the same "comapny_id" the rule doesn't fire as expected. In MongoDB fields are of type string for "code" and of type Int32 for "company_id". In above Rule::unique('mongodb.plico_user_groups', 'code') the "mongodb" part is the name of my connection and "plico_user_groups" is the name of the collection.
Please, someone can help?
Many thanks,
bye.
Beta Was this translation helpful? Give feedback.
All reactions