Did you google it?
Did you tried reading how unique work?
Just think, how does you believe the system know if that input is unique?
Y getting this error for mobile number unique validation
Did you google it?
Please help me
{
$this->validate($request, [
‘name’ => ‘required|max:255′,
’email’ => ‘required|unique:users|email|max:255’,
‘avatar’ => ‘image|max:3072’,
‘password’ => ‘required|min:6|confirmed’,
‘phone’ => ‘required|string|min:10’,
],[
‘phone.unique’ => ‘The phone number is already registered with us’
]);
try {
$users_create_permission = check_permission(‘userscreate’,Auth::user()->role_id);
if($users_create_permission==1) {
// $User = $request->all();
$User[‘phone’] = “+”.$request->phone1.$request->phone;
$User[‘password’] = bcrypt($request->password);
$url = env(‘DO_SPACES_ENDPOINT’) . ‘/’ . env(‘DO_SPACES_BUCKET’) . ‘/’;
if($request->hasFile(‘avatar’)) {
// $User[‘avatar’] = (‘storage/’.$request->avatar->store(‘user/profile’));
$image = $request->file(‘avatar’);
$name = str_slug($image->getClientOriginalName() . uniqid()) . ‘.’ . $image->getClientOriginalExtension();
$filePath = ‘images/B2C/’ . $name;
Storage::disk(‘do_spaces’)->put($filePath, file_get_contents($image));
$User[‘avatar’] = $url . $filePath;
}
$User[‘latitude’] = 0;
$User[‘longitude’] = 0;
$User = User::create($User);
// comments on 28/09/2019
$User->notify(new UserRegisteredNotification($User));
return back()->with(‘flash_success’,trans(‘user.created_success’,[‘name’=>$User->name]));
}else{
return back()->with(‘flash_error’,’You have no permission for this task’);
}
} catch (Exception $e) {
// return redirect()->route(‘admin.users.index’)->with(‘flash_error’, ‘Whoops! something went wrong.’);
print_r($e->getMessage());
exit;
return back()->with(‘flash_error’, ‘Whoops! something went wrong.’);
}
}

Please help me
I want one row of opening balance
Anybody please helpp
{
$this->validate($request, [
‘name’ => ‘required|max:255′,
’email’ => ‘required|unique:users|email|max:255’,
‘avatar’ => ‘image|max:3072’,
‘password’ => ‘required|min:6|confirmed’,
‘phone’ => ‘required|string|min:10’,
],[
‘phone.unique’ => ‘The phone number is already registered with us’
]);
try {
$users_create_permission = check_permission(‘userscreate’,Auth::user()->role_id);
if($users_create_permission==1) {
// $User = $request->all();
$User[‘phone’] = “+”.$request->phone1.$request->phone;
$User[‘password’] = bcrypt($request->password);
$url = env(‘DO_SPACES_ENDPOINT’) . ‘/’ . env(‘DO_SPACES_BUCKET’) . ‘/’;
if($request->hasFile(‘avatar’)) {
// $User[‘avatar’] = (‘storage/’.$request->avatar->store(‘user/profile’));
$image = $request->file(‘avatar’);
$name = str_slug($image->getClientOriginalName() . uniqid()) . ‘.’ . $image->getClientOriginalExtension();
$filePath = ‘images/B2C/’ . $name;
Storage::disk(‘do_spaces’)->put($filePath, file_get_contents($image));
$User[‘avatar’] = $url . $filePath;
}
$User[‘latitude’] = 0;
$User[‘longitude’] = 0;
$User = User::create($User);
// comments on 28/09/2019
$User->notify(new UserRegisteredNotification($User));
return back()->with(‘flash_success’,trans(‘user.created_success’,[‘name’=>$User->name]));
}else{
return back()->with(‘flash_error’,’You have no permission for this task’);
}
} catch (Exception $e) {
// return redirect()->route(‘admin.users.index’)->with(‘flash_error’, ‘Whoops! something went wrong.’);
print_r($e->getMessage());
exit;
return back()->with(‘flash_error’, ‘Whoops! something went wrong.’);
}
}
I don’t see the unique rule applied to phone, so is working fine.
{
$this->validate($request, [
‘name’ => ‘required|max:255′,
’email’ => ‘required|unique:users|email|max:255’,
‘avatar’ => ‘image|max:3072’,
‘password’ => ‘required|min:6|confirmed’,
‘phone’ => ‘required|unique|string|min:10’,
],[
‘phone.unique’ => ‘The phone number is already registered with us’
]);
try {
$users_create_permission = check_permission(‘userscreate’,Auth::user()->role_id);
if($users_create_permission==1) {
// $User = $request->all();
$User[‘phone’] = “+”.$request->phone1.$request->phone;
$User[‘password’] = bcrypt($request->password);
$url = env(‘DO_SPACES_ENDPOINT’) . ‘/’ . env(‘DO_SPACES_BUCKET’) . ‘/’;
if($request->hasFile(‘avatar’)) {
// $User[‘avatar’] = (‘storage/’.$request->avatar->store(‘user/profile’));
$image = $request->file(‘avatar’);
$name = str_slug($image->getClientOriginalName() . uniqid()) . ‘.’ . $image->getClientOriginalExtension();
$filePath = ‘images/B2C/’ . $name;
Storage::disk(‘do_spaces’)->put($filePath, file_get_contents($image));
$User[‘avatar’] = $url . $filePath;
}
$User[‘latitude’] = 0;
$User[‘longitude’] = 0;
$User = User::create($User);
// comments on 28/09/2019
$User->notify(new UserRegisteredNotification($User));
return back()->with(‘flash_success’,trans(‘user.created_success’,[‘name’=>$User->name]));
}else{
return back()->with(‘flash_error’,’You have no permission for this task’);
}
} catch (Exception $e) {
// return redirect()->route(‘admin.users.index’)->with(‘flash_error’, ‘Whoops! something went wrong.’);
print_r($e->getMessage());
exit;
return back()->with(‘flash_error’, ‘Whoops! something went wrong.’);
}
}
Sorry this was the code
What
When giving same phone number its throwing this error
Can you please say how
Just read this.