PHP Classes

File: app/Actions/Fortify/CreateNewUser.php

Recommend this page to a friend!
  Classes of Thierry Feuzeu   Jaxon DB Admin   app/Actions/Fortify/CreateNewUser.php   Download  
File: app/Actions/Fortify/CreateNewUser.php
Role: Class source
Content typex: text/plain
Description: Class source
Class: Jaxon DB Admin
Web application to manage SQL of databases
Author: By
Last change: Update of app/Actions/Fortify/CreateNewUser.php
Date: 1 month ago
Size: 1,016 bytes
 

Contents

Class file image Download
<?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;

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',
               
Rule::unique(User::class),
            ],
           
'password' => $this->passwordRules(),
        ])->
validate();

        return
User::create([
           
'name' => $input['name'],
           
'email' => $input['email'],
           
'password' => Hash::make($input['password']),
        ]);
    }
}