Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

120's avatar

Hello,

As you I was looking for hours to do that but nothing worked, I test everything ... suddenly the randomness of the doc I came across this:

'email' => Rule::unique('users')->where(function ($query) {
    return $query->where('account_id', 1);
})

https://laravel.com/docs/5.5/validation#rule-unique

and it works perfectly and moreover it is very flexible :)

AnnaEverson's avatar

I'm not good at coding, but thanks for the answers. They are really useful

Previous

Please or to participate in this conversation.