environments()->create([ 'name' => $name, 'branch' => $branch ?? $application->default_branch, 'status' => 'pending', 'scheduler_enabled' => true, 'scheduler_mode' => SchedulerMode::SINGLE, 'build_config' => [ 'php_version' => $phpVersion, 'document_root' => 'public', 'health_path' => '/up', 'js_build_command' => null, 'js_package_manager' => 'bun', ], ]); $web = $environment->services()->create([ 'organisation_id' => $application->organisation_id, 'name' => 'web', 'category' => ServiceCategory::APPLICATION, 'type' => ServiceType::LARAVEL, 'version' => "php-{$phpVersion}", 'version_track' => "php-{$phpVersion}", 'driver_name' => "laravel.php-{$phpVersion}", 'status' => ServiceStatus::NOT_INSTALLED, 'desired_replicas' => 1, 'deploy_policy' => DeployPolicy::WITH_ENVIRONMENT, 'process_roles' => ['web', 'scheduler'], 'config' => [ 'migration_mode' => 'auto', 'migration_timing' => 'pre_switch', 'migration_command' => 'php artisan migrate --force', 'document_root' => 'public', 'health_path' => '/up', 'js_build_command' => null, 'js_package_manager' => 'bun', ], ]); $environment->forceFill([ 'scheduler_target_service_id' => $web->id, ])->save(); return $environment->refresh(); } }