*/ class TalkFactory extends Factory { protected $model = Talk::class; /** * @return array */ public function definition(): array { return [ 'title' => rtrim(fake()->unique()->catchPhrase(), '.'), 'language' => (string) config('locales.default'), 'summary' => $this->eachLocale(fn () => fake()->sentence(14)), 'event' => fake()->randomElement([ 'Codemotion', 'T3chFest', 'JSDay', 'PHPBarcelona', 'Meetup Laravel', ]), 'city' => fake()->randomElement(['Madrid', 'Barcelona', 'Valencia', 'Sevilla']), 'held_at' => fake()->dateTimeBetween('-3 years'), 'video_url' => fake()->optional(0.6)->url(), 'slides_url' => fake()->optional(0.4)->url(), 'is_public' => true, ]; } /** @return array */ protected function eachLocale(callable $value): array { return collect(array_keys(config('locales.supported'))) ->mapWithKeys(fn (string $l) => [$l => $value($l)]) ->all(); } }