Check if a variable in a form is unique in 2 simultaneous models

1

You see, I have a form to register a new user, which has among its variables the email. These are the conditions you must meet:

  

'email' = > 'required | string | email | max: 255 | unique: users'

The condition unique:user prevents you from entering a value that is already in the user table User , but I also have another table called Tabu , in which I enter the emails of users banned and deleted from the first table . You can not use an email that appears in any of the 2 tables. How do I achieve it?

    
asked by Miguel Alparez 19.12.2018 в 21:04
source

1 answer

1

It should be as simple as using the validation rule twice:

'email' => 'required|string|email|max:255|unique:users|unique:tabu'

This would work if the name of the field is email in both tables, otherwise you would have to pass the name of the column that should be compared as well.

    
answered by 19.12.2018 / 21:18
source