#Know which model Validator should validate

6 messages · Page 1 of 1 (latest)

bleak pawn
#

I have two user models one in Models/user.php the second in Models/omni/User.php.
How do i make this validator check if the user is exits in the omi User model

            'email' => 'required|email|unique:users',
            'name' => 'required|fullname|unique:users',
            'address' => 'required',
            'password' => 'required',
        ]);```
how do i define which user table it should validate this required|email|unique:users on becuase i have two users table in two databases
scarlet umbra
#

@bleak pawn If they are two databases then presumably each model uses a different database connection, is that right? The unique validator is based on the table name rather than the model name, and you can prefix it with the name of your connection as defined in your database config file. e.g. 'unique:omni.users' or whatever connection name you are using.

bleak pawn
scarlet umbra
scarlet umbra
#

Glad to hear it! Can you tag this thread as "solved" please?