Skip to main content

ammannbe/RecipeManager

37 stars
3 code files
View ammannbe/RecipeManager on GitHub

composer.json

Open in GitHub
{
//
"require": {
"php": "^7.4|^8.0",
//
"laravel/fortify": "^1.7"
},
//
}

app/Actions/Fortify/CreateNewUser.php

Open in GitHub
use 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 GitHub
use Laravel\Fortify\Fortify;
use App\Actions\Fortify\CreateNewUser;
use Illuminate\Support\ServiceProvider;
 
class FortifyServiceProvider extends ServiceProvider
{
public function boot()
{
Fortify::createUsersUsing(CreateNewUser::class);
//
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.