Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer collective, backed by the Pireon OAuth identity server. The public site is a separate, server-rendered application consuming /api/public/v1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
71 lines
1.9 KiB
PHP
71 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\ApplicationKind;
|
|
use App\Enums\ApplicationStatus;
|
|
use App\Models\Application;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<Application>
|
|
*/
|
|
class ApplicationFactory extends Factory
|
|
{
|
|
protected $model = Application::class;
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'call_id' => null,
|
|
'call_title' => null,
|
|
'kind' => ApplicationKind::Contribute,
|
|
'status' => ApplicationStatus::New,
|
|
'name' => fake()->name(),
|
|
'email' => fake()->unique()->safeEmail(),
|
|
'organisation' => null,
|
|
'message' => fake()->paragraph(),
|
|
'hours_per_week' => fake()->randomElement([2, 3, 4, 6, null]),
|
|
'links' => ['github' => 'https://github.com/'.fake()->userName()],
|
|
'locale' => (string) config('locales.default'),
|
|
'ip_hash' => Application::hashIp(fake()->ipv4()),
|
|
];
|
|
}
|
|
|
|
public function forCall(int $callId, string $title = 'Backend'): static
|
|
{
|
|
return $this->state(fn () => [
|
|
'call_id' => $callId,
|
|
'call_title' => $title,
|
|
]);
|
|
}
|
|
|
|
public function request(): static
|
|
{
|
|
return $this->state(fn () => [
|
|
'kind' => ApplicationKind::Request,
|
|
'organisation' => fake()->company(),
|
|
'hours_per_week' => null,
|
|
'links' => null,
|
|
]);
|
|
}
|
|
|
|
public function handled(ApplicationStatus $status = ApplicationStatus::Contacted): static
|
|
{
|
|
return $this->state(fn () => [
|
|
'status' => $status,
|
|
'handled_at' => now(),
|
|
]);
|
|
}
|
|
|
|
public function spam(): static
|
|
{
|
|
return $this->state(fn () => ['status' => ApplicationStatus::Spam]);
|
|
}
|
|
}
|