*/ class CallFactory extends Factory { protected $model = Call::class; /** * @return array */ 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 */ protected function eachLocale(callable $value): array { return collect(array_keys(config('locales.supported'))) ->mapWithKeys(fn (string $l) => [$l => $value($l)]) ->all(); } }