Support the ongoing development of Laravel.io →
Forms Validation
Last updated 3 months 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 5 years ago.
0

Sign in to participate in this thread!

LoadForge

Your banner here too?

warrio4 warrio4 warrio4 Joined 7 Feb 2017

Moderators

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

Your logo here?

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

© 2022 Laravel.io - All rights reserved.