Se adjuntan columnas de apellido paterno y materno para el usuario y validaciones de registro de usuario independiente
This commit is contained in:
@@ -16,28 +16,27 @@ class CreateNewUser implements CreatesNewUsers
|
||||
|
||||
public function create(array $input)
|
||||
{
|
||||
|
||||
if( $input['plantels'] == 0){
|
||||
throw ValidationException::withMessages([
|
||||
'plantels' => ['Debes elegir un plantel']
|
||||
]);
|
||||
}
|
||||
|
||||
Validator::make($input, [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'apellidoPaterno' => ['required', 'string', 'max:255'],
|
||||
'apellidoMaterno' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'telefono' => ['required', 'digits:10', 'unique:users,telefono'],
|
||||
'password' => $this->passwordRules(),
|
||||
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '',
|
||||
])->validate();
|
||||
|
||||
|
||||
|
||||
if (User::where('email', $input['email'])
|
||||
->orWhere('telefono', $input['telefono'])
|
||||
->exists()) {
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
'email' => ['El correo o teléfono ya están registrados.']
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
$user = User::create([
|
||||
'name' => $input['name'],
|
||||
'apellidoPaterno' => $input['apellidoPaterno'],
|
||||
'apellidoMaterno' => $input['apellidoMaterno'],
|
||||
'email' => $input['email'],
|
||||
'telefono' => $input['telefono'],
|
||||
'direccion' => "",
|
||||
@@ -59,8 +58,6 @@ class CreateNewUser implements CreatesNewUsers
|
||||
|
||||
$prospecto->prospectos()->sync([$user->id]);
|
||||
|
||||
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ class UserController extends Controller
|
||||
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'apellidoPaterno' => $request-> apellidoPaterno,
|
||||
'apellidoMaterno' => $request-> apellidoMaterno,
|
||||
'email' => $request->email,
|
||||
'telefono' => $request->telefono ?? null,
|
||||
'direccion' => $request->direccion ?? null,
|
||||
|
||||
@@ -26,6 +26,8 @@ class User extends Authenticatable
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'apellidoPaterno',
|
||||
'apellidoMaterno',
|
||||
'email',
|
||||
'telefono',
|
||||
'direccion',
|
||||
|
||||
Reference in New Issue
Block a user