mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-05-03 16:24:55 +00:00
1f0bfba0d3
🛠️ **Factory:** Created factories for `TwitterAccount`, `EmailCampaign`, `EmailTexts`, and `BookCase`. ✨ **Helper:** Added `NostrHelper` with methods for generating fake/mocked Nostr data. ⬆️ **Dependencies:** Updated multiple Composer dependencies including `laravel/framework`, `astrotomic/laravel-translatable`, and others to their latest versions.
70 lines
2.0 KiB
PHP
70 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\User;
|
|
use Database\Factories\Helpers\NostrHelper;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends Factory<User>
|
|
*/
|
|
class UserFactory extends Factory
|
|
{
|
|
protected static ?string $password;
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$name = fake()->firstName().' '.fake()->lastName();
|
|
|
|
return [
|
|
'name' => $name,
|
|
'email' => fake()->unique()->safeEmail(),
|
|
'email_verified_at' => now(),
|
|
'password' => static::$password ??= Hash::make('password'),
|
|
'remember_token' => Str::random(10),
|
|
'reputation' => fake()->numberBetween(0, 1000),
|
|
'current_language' => fake()->randomElement(['de', 'en']),
|
|
'timezone' => 'Europe/Berlin',
|
|
'is_lecturer' => fake()->boolean(20),
|
|
'nostr' => fake()->boolean(70) ? NostrHelper::randomNpub() : null,
|
|
'lightning_address' => fake()->boolean(40) ? NostrHelper::randomLightningAddress($name) : null,
|
|
'lnurl' => null,
|
|
'node_id' => null,
|
|
'paynym' => null,
|
|
'lnbits' => null,
|
|
'public_key' => null,
|
|
'change' => null,
|
|
'change_time' => null,
|
|
'profile_photo_path' => null,
|
|
];
|
|
}
|
|
|
|
public function unverified(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'email_verified_at' => null,
|
|
]);
|
|
}
|
|
|
|
public function lecturer(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'is_lecturer' => true,
|
|
]);
|
|
}
|
|
|
|
public function withNostr(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'nostr' => NostrHelper::randomNpub(),
|
|
'lightning_address' => NostrHelper::randomLightningAddress($attributes['name'] ?? null),
|
|
]);
|
|
}
|
|
}
|