Stelle das U0-Fundament mit CMS, Mitgliedern und Filament bereit.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
89b35ac480
commit
2035c46edd
130 files changed
+18519
-50
No files matched your search
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Identity;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class RegisterAccount
|
||||
{
|
||||
public function register(string $name, string $email, string $password, bool $adult): User
|
||||
{
|
||||
if (! $adult) {
|
||||
throw ValidationException::withMessages([
|
||||
'adult' => 'Die Plattform richtet sich an Erwachsene. Ein Konto setzt die Bestätigung voraus.',
|
||||
]);
|
||||
}
|
||||
|
||||
return DB::transaction(function () use ($name, $email, $password): User {
|
||||
$party = Party::query()->create([
|
||||
'type' => PartyType::Person,
|
||||
'display_name' => $name,
|
||||
]);
|
||||
|
||||
Profile::query()->create([
|
||||
'party_id' => $party->id,
|
||||
'display_name' => $name,
|
||||
'visibility' => ['display_name' => 'private'],
|
||||
]);
|
||||
|
||||
return User::query()->create([
|
||||
'party_id' => $party->id,
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'password' => $password,
|
||||
'status' => AccountStatus::Aktiv,
|
||||
'confirmed_adult_at' => now(),
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user