Juan Felipe Zapata Moreno c6c2f78d16 Initial Commit
2025-08-12 09:36:02 -06:00

41 lines
1.3 KiB
PHP

<?php namespace App\Actions\Fortify;
use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Laravel\Fortify\Contracts\CreatesNewUsers;
use Laravel\Jetstream\Jetstream;
class CreateNewUser implements CreatesNewUsers
{
use PasswordValidationRules;
/**
* Validate and create a newly registered user.
*
* @param array $input
* @return \App\Models\User
*/
public function create(array $input)
{
Validator::make($input, [
'name' => ['required', 'string', 'max:255'],
'paternal' => ['required', 'string', 'max:255'],
'maternal' => ['nullable', 'string', 'max:255'],
'phone' => ['nullable', 'numeric', 'digits:10', 'unique:users'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => $this->passwordRules(),
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '',
])->validate();
return User::create([
'name' => $input['name'],
'paternal' => $input['paternal'],
'maternal' => $input['maternal'],
'phone' => $input['phone'],
'email' => $input['email'],
'password' => Hash::make($input['password']),
]);
}
}