У меня есть следующий код:
$postalcode=$data['postal_code'];
return Validator::make($data, [
'name' => ['required','string','max:255'],
'email' => ['required','string','email','max:255','unique:users'],
'password' => ['required','string','min:8','confirmed'],
'postal_code' =>['required','string','max:255',Rule::exists('zipcodes')->where(function ($query) {
$query->whereRaw('REPLACE(POSTAL_CODE,\' \',\'\')= ?',[str_replace(' ','',$postalcode)]);
})],
]);
но выдает следующую ошибку:
«Неопределенная переменная: почтовый индекс»
так что я хочу передать переменную $ postalcode в правило, но я не знаю как?