I have table in which i'm trying to store email addresses. These email addresses will be save with user_id
.
For example in email_list
table
|ID | user_id | email |
...............................
| 1 | 101 | john@gmail.com |
...............................
| 2 | 102 | john@gmail.com |
In above table you can see same email addresses save with different user_id
, that's it what i'm trying to do.
Currently i'm trying simple laravel validation like this.
'email' => 'required|unique:email_list|email',
So is there any way to check already exist email addresses if row has same user_id
? I'm using laravel 5.2. I would like to appreciate if someone guide me. Thank you
Edited After 3 Hours
I also add same question in the github as issue. A person is saying that i have to create own validation rule.
It is against of exist rule.
First of all, the exist rule check based on the condition the fields is avail or not.
I think, if we used it as opposite then it is useful for you.
Ex:-
i.e.,
otherwise,
while using Input & import the
and change message content
Please try these and reply what happened.. or is it work for you..?
Forcing A Unique Rule To Ignore A Given ID
You can specify an ID to be ignored as the optional third parameter. Furthermore, if your table uses a primary key column name other than id, you may specify it as the optional fourth parameter
So in your case, it'd be as follows