Validate Laravel email | Distinct Tables

Asked

Viewed 439 times

1

I have a question regarding the unique field validation in the Laravel. I have two tables with no relationships (users and companies), both have a column email.

I need to validate the field email uniquely in the two different tables, that is, when registering the company I need to check if the email exists in the table companies and in the table users.

I tried to do it in validation

'email' => 'required|unique:companies' 
'email' => 'required|unique:users'

I did not succeed in this attempt. What is the best way to do this?

1 answer

1


I solved my problem by making a small adjustment in the code as below:

'email' => 'required|unique:companies, email', 
'email' => 'required|unique:users, email',

I passed the column of the tables in the validation. I do not know why but I believe that the previous form should have worked...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.