Answers for "laravel unique except"

PHP
1

laravel unique validation

unique:table,column,except,idColumn

############## Example : ################

############### For Updating  
//rules
'email' => 'unique:users,email_address,' . $userId,

############### For Creating 
//rules
'email' => 'unique:users,email_address',
Posted by: Guest on October-26-2020
0

laravel unique except, some operation on query

public function rules()
    {
        return [
            'name' => [
                'required',
                'email',
                Rule::unique('users', 'email')
                    ->where(static function ($query) {
                        return $query->whereNull('deleted_at');
                    })
                    ->ignore($this->user),
            ]
        ];
    }
Posted by: Guest on May-10-2021

Browse Popular Code Answers by Language