laravel validation two columns unique code example

Example 1: unique check with multiple columns laravel validation

'name' => 'unique:table,field,NULL,id,field1,value1,field2,value2,field3,value3'

Example 2: laravel unique validation on multiple columns

'mobile_no' 
  => 'unique:users,mobile_no,NULL,id,country_id,'.request('country_id');

Example 3: unique check two clolumn in laravel validation

'data.ip' => ['required', 'unique:servers,ip,'.$this->id.',NULL,id,hostname,'.$request->input('hostname')]

Example 4: unique check two clolumn in laravel validation

'data.ip' => ['required', 'unique:servers,ip,'.$this->id.','.$request->input('id').',id,hostname,'.$request->input('hostname')]

Tags:

Php Example