芝麻web文件管理V1.00
编辑当前文件:/home/forge/stage.herta-bht.smartcon-survey.com/app/Services/ExternalDataService.php
connection = DB::connection($connectionName); } /** * Set the table for the query. * * @param string $table The name of the table * @return self The service instance */ public static function table(string $table): self { if (! isset(self::$instance)) { self::instance(); } self::$instance->query = self::$instance->connection->table($table); return self::$instance; } /** * Set the columns to select in the query. * * @param array $columns The columns to select * @return self The service instance */ public static function select(array $columns): self { self::$instance->query->select($columns); return self::$instance; } /** * Apply filters to the query. * * @param array $filters The filters to apply * @return self The service instance */ public static function filters(array $filters): self { self::$instance->query->where($filters); return self::$instance; } /** * Get the query builder instance. * * @return Builder The query builder instance */ public static function query(): Builder { return self::$instance->query; } /** * Execute the query and get the results. * * @return Collection|EloquentCollection The query results */ public static function get(): Collection|EloquentCollection { return self::$instance->query->get(); } /** * Get the waves for a specific country. * * @param int $countryId The ID of the country * @return array The waves for the country */ public static function getWaves(int $countryId): array { if (! isset(self::$instance)) { self::instance(); } self::table(config('database.connections.survey_db.quota_table')); // Get last uploaded wave $waves = DataUpload::select(['wave'])->where('country_id', $countryId) ->pluck('wave')->toArray(); // Get waves from survey database $surveyWaves = self::$instance->query->select('scpid as wave') ->where('scpid', '<', 9900) ->distinct() ->get(); return $surveyWaves->reduce(function ($curry, $wave) use ($waves) { if (in_array($wave->wave, $waves, true)) { $curry[-$wave->wave] = 'Wave '.$wave->wave.' (already uploaded)'; } else { $curry[$wave->wave] = 'Wave '.$wave->wave; } return $curry; }, []); } }