*/ class RepositoryFactory extends Factory { protected $model = Repository::class; /** * @return array */ public function definition(): array { $owner = 'colectivo'; $name = Str::slug(fake()->unique()->words(2, true)); return [ 'provider' => GitProvider::Gitea, 'full_name' => "{$owner}/{$name}", 'is_primary' => true, 'show_publicly' => true, 'html_url' => "https://git.pireon.test/{$owner}/{$name}", 'description' => fake()->sentence(), 'default_branch' => 'main', 'primary_language' => fake()->randomElement(['PHP', 'TypeScript', 'Rust', 'Go', 'Python']), 'license' => fake()->randomElement(['MIT', 'AGPL-3.0', 'Apache-2.0']), 'topics' => ['open-source', 'community'], 'languages' => ['PHP' => 120000, 'Blade' => 30000], 'stars' => fake()->numberBetween(0, 400), 'forks' => fake()->numberBetween(0, 40), 'watchers' => fake()->numberBetween(0, 30), 'open_issues_count' => fake()->numberBetween(0, 25), 'contributors_count' => fake()->numberBetween(1, 12), 'is_archived' => false, 'is_fork' => false, 'pushed_at' => fake()->dateTimeBetween('-2 months'), 'repo_created_at' => fake()->dateTimeBetween('-4 years', '-1 year'), 'last_synced_at' => now(), ]; } /** * Nothing pushed for a long time — what the public site uses to avoid * advertising dead work as live. */ public function dormant(): static { return $this->state(fn () => [ 'pushed_at' => now()->subYears(2), ]); } public function failing(): static { return $this->state(fn () => [ 'sync_error' => 'The repository [colectivo/gone] does not exist.', 'sync_failures' => 5, ]); } public function hidden(): static { return $this->state(fn () => ['show_publicly' => false]); } }