Files
timebank-cc-public/app/Actions/Fortify/CreateNewUser.php
Ronald Huynen 2547717edb Initial commit
2026-03-23 21:37:59 +01:00

53 lines
1.6 KiB
PHP

<?php
namespace App\Actions\Fortify;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Laravel\Fortify\Contracts\CreatesNewUsers;
use Laravel\Jetstream\Jetstream;
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::make($input, [
'name' => ['required', 'string','max:25', 'unique:users'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => $this->passwordRules(),
// 'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '',
])->validate();
$user = User::create([
'name' => $input['name'],
'email' => $input['email'],
'password' => Hash::make($input['password']),
]);
// Always move this section to the final registration.
Session([
'activeProfileType' => User::class,
'activeProfileId' => Auth::guard('web')->user()->id,
'activeProfileName'=> Auth::guard('web')->user()->name,
'activeProfilePhoto'=> Auth::guard('web')->user()->profile_photo_path,
'firstLogin' => true
]);
//TODO: Welcome and introduction with Session('firstLogin') on rest of site views
return $user;
}
}