M
M
maestro8812018-06-03 17:58:46
symfony
maestro881, 2018-06-03 17:58:46

How to check for duplicate in Symfony 4?

There is a method in laravel to avoid recording duplicates:

User::firstOrCreate(array(
    'name' => $input['name'],
    'email' => $input['email'],
    'password' => $input['password'])
);

Please help how can I do this on symfony 4

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nicandr, 2018-06-08
@nicandr

Hello use Unique entity @UniqueEntity(fields={"email"}, message="Exist")
https://symfony.com/doc/current/reference/constrai...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question