mirror of https://github.com/realodix/urlhub.git
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.
34 lines
944 B
34 lines
944 B
<?php
|
|
|
|
namespace App\Actions\Fortify;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Facades\Validator;
|
|
use Illuminate\Validation\Rule;
|
|
use Laravel\Fortify\Contracts\CreatesNewUsers;
|
|
use Laravel\Fortify\Rules\Password;
|
|
|
|
class CreateNewUser implements CreatesNewUsers
|
|
{
|
|
/**
|
|
* Validate and create a newly registered user.
|
|
*
|
|
* @return \App\Models\User
|
|
*/
|
|
public function create(array $input)
|
|
{
|
|
Validator::make($input, [
|
|
'name' => ['required', 'string', 'max:50'],
|
|
'email' => ['required', 'string', 'email', 'max:255', Rule::unique(User::class)],
|
|
'password' => ['required', 'string', new Password, 'confirmed'],
|
|
])->validate();
|
|
|
|
return User::create([
|
|
'name' => $input['name'],
|
|
'email' => $input['email'],
|
|
'password' => Hash::make($input['password']),
|
|
]);
|
|
}
|
|
}
|