fix: 🐛 unique username validation not handle
This commit is contained in:
parent
fd50bf71f4
commit
8ad3737404
1 changed files with 14 additions and 1 deletions
|
|
@ -54,11 +54,12 @@ class StoreCustomerRequest extends FormRequest
|
||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
|
$customerId = auth('club')->user();
|
||||||
$countryList = implode(',', Country::getValidIsoAplha2Codes());
|
$countryList = implode(',', Country::getValidIsoAplha2Codes());
|
||||||
return [
|
return [
|
||||||
'lastname' => 'required|string|max:255',
|
'lastname' => 'required|string|max:255',
|
||||||
'firstname' => 'required|string|max:255',
|
'firstname' => 'required|string|max:255',
|
||||||
'username' => 'required|string|max:255',
|
'username' => ['required','string', 'max:255', Rule::unique('customers', 'username')->ignore($customerId)],
|
||||||
'phone' => "nullable|max:255|between:1,100|phone:{$countryList}",
|
'phone' => "nullable|max:255|between:1,100|phone:{$countryList}",
|
||||||
'address' => 'required|string|min:1|max:255',
|
'address' => 'required|string|min:1|max:255',
|
||||||
'address2' => 'nullable|string|min:1|max:255',
|
'address2' => 'nullable|string|min:1|max:255',
|
||||||
|
|
@ -117,4 +118,16 @@ class StoreCustomerRequest extends FormRequest
|
||||||
'opt_in' => trans('validation.custom.newsletter'),
|
'opt_in' => trans('validation.custom.newsletter'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom messages for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function messages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'username.unique' => trans('Le pseudo est déjà pris'),
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue