Created
November 22, 2020 01:01
-
-
Save tomredman/9fa98c0e6b21cad3a83934d96c6bf097 to your computer and use it in GitHub Desktop.
CreateNewUser.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Actions\Fortify; | |
use App\Models\User; | |
use Illuminate\Support\Facades\Hash; | |
use Illuminate\Support\Facades\Validator; | |
use Laravel\Fortify\Contracts\CreatesNewUsers; | |
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 = Validator::make($input, [ | |
'name' => ['required', 'string', 'max:255'], | |
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], | |
'password' => $this->passwordRules(), | |
])->validate(); | |
return User::create([ | |
'name' => $input['name'], | |
'email' => $input['email'], | |
'password' => Hash::make($input['password']), | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment