How to prevent insert email if already exist with specific id in laravel?

前端 未结 2 605
天命终不由人
天命终不由人 2020-12-21 09:23

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 tabl

2条回答
  •  再見小時候
    2020-12-21 09:25

    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:-

         'email' => 'exists:email_list,email,user_id,!102'
    

    i.e.,

         'email' => 'exists:email_list,email,user_id,!'. $user_id        
    

    otherwise,

         'email' => 'exists:email_list,email,user_id,!'. Input::get(user_id)
    

    while using Input & import the

        use Illuminate\Support\Facades\Input;        
    

    and change message content
    Please try these and reply what happened.. or is it work for you..?

提交回复
热议问题