use Illuminate\Validation\Rule;
exists 去除软删除字段的校验
php
$validator = \Validator::make($data, [
'phone_new' => [
Rule::exists('users', 'phone')->whereNull('deleted_at'),
]
], [
'phone_new.exists' => '手机号不存在',
]);
unique 去除软删除字段的校验
php
// 新增
'email'=>'required|email|unique:users,email,NULL,id,deleted_at,NULL'
'email' => ['required', Rule::unique('users')->whereNull('deleted_at')]
// 修改
'email'=> "required|email|unique:users,email,{$this->id},id,deleted_at,NULL"
'email' => ['required', Rule::unique('users')->ignore($this->id)->whereNull('deleted_at')]
补充
冒号后面6个空,前两个不用说,中间两个表示忽略id=$this->id,后面两个表示加上限定条件deleted_at=null