Laravel Validation (unique rule)

Laravel Validation (unique rule)

Content Index :

Laravel Validation (unique rule)
Tag : validation , By : BinaryBoy
Date : November 24 2020, 01:01 AM

will help you i use a separate class for validation so it looks like , This will do your trick
class UserValidation {

    protected static $rules = [
        'email'    => 'required|email|unique:users,email',
        'password' => 'required|alpha_dash|min:4',

    public static function validate($input, $id = false)
        $rules = self::$rules;

            $rules['email'] .=','.$id;
        return Validator::make($input, $rules);

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Laravel 4 - how to use a unique validation rule / unique columns with soft deletes?

Tag : laravel , By : dantino
Date : March 29 2020, 07:55 AM
This might help you This sounds like an issue with your business logic rather than a technical problem.
The purpose of a soft delete is to allow for the possibility that the soft-deleted record may be restored in the future. However, if your application needs uniqueness of email (which is completely normal), you wouldn't want to both create a new user with that email address and be able to restore the old one as this would contravene the uniqueness requirement.

Laravel validation: unique rule 4th parameter

Tag : php , By : CrookedNumber
Date : March 29 2020, 07:55 AM
wish helps you Ah nuts, I think the penny has just dropped.
Correct me if I'm wrong, but the 4th parameter is related to the 3rd parameter in that it allows us to specify which column we want to check when ignoring the ID specified in 3. If it's not id.
'email' => 'unique:users,email_address,NULL,user_id,account_id,1'

Laravel rule validation unique for id

Tag : php , By : jrf
Date : March 29 2020, 07:55 AM
hope this fix your issue Check the laravel validation documentation. You can specify the table, column and id to ignore.
'email' => 'unique:users,email_address,'.$user->id
'email' => 'unique:users,email_address,NULL,id,account_id,1'

laravel validation unique rule

Tag : php , By : cnemelka
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , The unique rule is meant to check the value to be unique in the database. The way the validator checks for "uniqueness" in the database is using a 'Presence verifier'. You didn't provide any Presence verifier and that's why you see the error. To provide a presence verifier you need to add this extra code
$presenceVerifier = new MyPresenceVerifier();

Laravel 5.1 mocking 'unique' validation rule

Tag : php , By : user165871
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
Privacy Policy - Terms - Contact Us © scrbit.com