*/ class MemberFactory extends Factory { protected $model = Member::class; /** * @return array */ public function definition(): array { $name = fake()->name(); $handle = Str::slug($name).fake()->unique()->numberBetween(1, 9999); return [ 'user_id' => null, 'name' => $name, 'slug' => $handle, 'headline' => $this->eachLocale(fn (string $l) => fake()->jobTitle()." ({$l})"), 'bio' => $this->eachLocale(fn () => fake()->paragraph()), 'github_username' => $handle, 'links' => [ 'github' => "https://github.com/{$handle}", 'website' => fake()->optional()->url(), ], 'is_public' => true, 'is_founder' => false, 'joined_at' => fake()->dateTimeBetween('-4 years'), 'position' => fake()->numberBetween(0, 20), ]; } public function founder(): static { return $this->state(fn () => ['is_founder' => true]); } /** * Someone who has moved on. Their work stays on the site. */ public function past(): static { return $this->state(fn () => ['left_at' => fake()->dateTimeBetween('-1 year')]); } public function hidden(): static { return $this->state(fn () => ['is_public' => false]); } /** @return array */ protected function eachLocale(callable $value): array { return collect(array_keys(config('locales.supported'))) ->mapWithKeys(fn (string $l) => [$l => $value($l)]) ->all(); } }