Support the ongoing development of Laravel.io →
Forms Validation
Last updated 1 year ago.
0

Answer given here: http://stackoverflow.com/questions/42115930/laravel-form-valid...

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'],
]);
Last updated 7 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

warrio4 warrio4 Joined 7 Feb 2017

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.