*/ class SiteFactory extends Factory { /** * Associated model. * * @var class-string<\App\Models\Site> */ #[\Override] protected $model = Site::class; /** * Define the model's default state. * * @return array */ public function definition(): array { // Get random project manager or create one. $enumValue = UserRoleRegistry::get('project-manager')->value; $projectManager = User::getModelsCached() ->where('published', true) ->where('role', $enumValue) ->shuffle() ->first() ?? User::factory()->create([ 'published' => true, 'role' => $enumValue, ]); return [ 'name' => fake()->unique()->words(3, true), 'url_re7' => fake()->boolean(75) ? fake()->unique()->url() : null, 'url_prod' => fake()->boolean(75) ? fake()->unique()->url() : null, 'project_manager_id' => fake()->boolean(75) ? $projectManager->getKey() : null, 'gitlab_project_id' => GitlabProject::factory(), ]; } }