Validate unique email Laravel | Different Tables

1

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

I need to validate the email field uniquely in the two distinct tables, ie at the time of registering the company I need to check that email exists in the companies table and in the users table. p>

I tried to do this in the validation

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

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

    
asked by anonymous 22.03.2017 / 12:05

1 answer

1

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

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

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

    
27.03.2017 / 14:14