-
composer.json
Open in GitHub{ // "require": { "php": "^7.4|^8.0", // "laravel/fortify": "^1.7" }, // }
-
app/Actions/Fortify/CreateNewUser.php
Open in GitHubuse App\Models\Users\User; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Laravel\Fortify\Contracts\CreatesNewUsers; class CreateNewUser implements CreatesNewUsers { use PasswordValidationRules; public function create(array $input) { Validator::make($input, [ 'name' => ['required', 'string', 'max:255', 'unique:authors,name'], 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'password' => $this->passwordRules(), ])->validate(); $user = User::create([ 'email' => $input['email'], 'password' => Hash::make($input['password']), ]); $user->author()->create([ 'name' => $input['name'], ]); return $user; } }
-
app/Providers/FortifyServiceProvider.php
Open in GitHubuse Laravel\Fortify\Fortify; use App\Actions\Fortify\CreateNewUser; use Illuminate\Support\ServiceProvider; class FortifyServiceProvider extends ServiceProvider { public function boot() { Fortify::createUsersUsing(CreateNewUser::class); // } }