added validation on sub-admin

This commit is contained in:
Ritikesh yadav
2024-05-21 15:21:37 +05:30
parent 76ca511a84
commit b6c168087c
4 changed files with 36 additions and 19 deletions

View File

@@ -82,10 +82,15 @@ class ManageSubAdminController extends Controller
return response()->json(['status' => 400, 'message' => $validationMessage]);
}
// $principalType = Iam_Principal_Type::find($request->role_type);
$alreadyExists = User::where('email',$request->email)->orWhere('contact_number',$request->contact_number)->exists();
if($alreadyExists)
$emailAlreadyExists = User::where('email',$request->email)->exists();
$contactAlreadyExists = User::where('contact_number',$request->contact_number)->exists();
if($emailAlreadyExists)
{
return response()->json(['status' => 400, 'message' =>'email or mobile number already exists']);
return response()->json(['status' => 400, 'message' =>'email should be unique']);
}
if($contactAlreadyExists)
{
return response()->json(['status' => 400, 'message' =>'Mobile number should be unique']);
}
// defining user type