Skip to content

Instantly share code, notes, and snippets.

@tomredman
Created November 22, 2020 01:01
Show Gist options
  • Select an option

  • Save tomredman/9fa98c0e6b21cad3a83934d96c6bf097 to your computer and use it in GitHub Desktop.

Select an option

Save tomredman/9fa98c0e6b21cad3a83934d96c6bf097 to your computer and use it in GitHub Desktop.

Revisions

  1. tomredman created this gist Nov 22, 2020.
    34 changes: 34 additions & 0 deletions CreateNewUser.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    <?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']),
    ]);
    }
    }