Answer given here: http://stackoverflow.com/questions/42115930/laravel-form-validation-unique-using-2-fields/42116158#42116158
Validator::extend('uniqueFirstAndLastName', function ($attribute, $value, $parameters, $validator) {
$count = DB::table('people')->where('firstName', $value)
->where('lastName', $parameters[0])
->count();
return $count === 0;
});
return Validator::make($data, [
'uniqueFirstAndLastName:' . $data['lastName'],
]);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community