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>
62 lines
1.9 KiB
PHP
62 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\CallStatus;
|
|
use App\Models\Call;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends Factory<Call>
|
|
*/
|
|
class CallFactory extends Factory
|
|
{
|
|
protected $model = Call::class;
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$role = fake()->randomElement([
|
|
'Frontend', 'Backend', 'Diseño', 'DevOps', 'QA', 'Documentación',
|
|
]);
|
|
$title = "{$role} · ".rtrim(fake()->unique()->catchPhrase(), '.');
|
|
|
|
return [
|
|
'title' => $this->eachLocale(fn (string $l) => "{$title} ({$l})"),
|
|
'slug' => $this->eachLocale(fn (string $l) => Str::slug("{$title}-{$l}")),
|
|
'description' => $this->eachLocale(fn () => fake()->paragraph()),
|
|
'what_you_get' => $this->eachLocale(fn () => fake()->sentence(12)),
|
|
'status' => CallStatus::Open,
|
|
// The honest ask: a few hours a week, for a bounded stretch.
|
|
'hours_per_week' => fake()->randomElement([2, 3, 4, 5, 6, 8]),
|
|
'duration_weeks' => fake()->randomElement([4, 8, 12, 24]),
|
|
'seniority' => fake()->randomElement(['junior', 'mid', 'any']),
|
|
'opens_at' => now()->subWeeks(2),
|
|
'closes_at' => fake()->optional(0.5)->dateTimeBetween('+2 weeks', '+3 months'),
|
|
];
|
|
}
|
|
|
|
public function closed(): static
|
|
{
|
|
return $this->state(fn () => ['status' => CallStatus::Closed]);
|
|
}
|
|
|
|
public function filled(): static
|
|
{
|
|
return $this->state(fn () => ['status' => CallStatus::Filled]);
|
|
}
|
|
|
|
/** @return array<string, string> */
|
|
protected function eachLocale(callable $value): array
|
|
{
|
|
return collect(array_keys(config('locales.supported')))
|
|
->mapWithKeys(fn (string $l) => [$l => $value($l)])
|
|
->all();
|
|
}
|
|
}
|