You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1012 B
36 lines
1012 B
3 months ago
|
<?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<string, string> $input
|
||
|
*/
|
||
|
public function create(array $input): User
|
||
|
{
|
||
|
Validator::make($input, [
|
||
|
'name' => ['required', 'string', 'max:255'],
|
||
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||
|
'password' => $this->passwordRules(),
|
||
|
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '',
|
||
|
])->validate();
|
||
|
|
||
|
return User::create([
|
||
|
'name' => $input['name'],
|
||
|
'email' => $input['email'],
|
||
|
'password' => Hash::make($input['password']),
|
||
|
]);
|
||
|
}
|
||
|
}
|