mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2026-05-20 10:04:53 +00:00
cb61d9d543
🎨 Refactor `Lecturer` model to include new fields and factory usage 🔧 Update `DatabaseSeeder` to handle default seeds 🛠️ Enhance `einundzwanzig` database configuration for SQLite compatibility
50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\SecurityAttempt;
|
|
use Illuminate\Auth\Access\AuthorizationException;
|
|
use Illuminate\Auth\AuthenticationException;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Validation\ValidationException;
|
|
|
|
/**
|
|
* @extends Factory<SecurityAttempt>
|
|
*/
|
|
class SecurityAttemptFactory extends Factory
|
|
{
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'ip_address' => fake()->ipv4(),
|
|
'user_agent' => fake()->userAgent(),
|
|
'method' => fake()->randomElement(['GET', 'POST']),
|
|
'url' => fake()->url(),
|
|
'route_name' => fake()->randomElement(['association.profile', 'association.elections', 'association.projectSupport']),
|
|
'exception_class' => fake()->randomElement([
|
|
ValidationException::class,
|
|
AuthenticationException::class,
|
|
AuthorizationException::class,
|
|
]),
|
|
'exception_message' => fake()->sentence(),
|
|
'component_name' => fake()->randomElement(['association.profile', 'association.election.show']),
|
|
'target_property' => fake()->randomElement(['name', 'email', 'npub']),
|
|
'payload' => ['attempt' => fake()->word()],
|
|
'severity' => fake()->randomElement(['low', 'medium', 'high', 'critical']),
|
|
];
|
|
}
|
|
|
|
public function high(): static
|
|
{
|
|
return $this->state(fn () => ['severity' => 'high']);
|
|
}
|
|
|
|
public function critical(): static
|
|
{
|
|
return $this->state(fn () => ['severity' => 'critical']);
|
|
}
|
|
}
|