getLocale(); $platform = config('app.timebank_config'); // Get the base path for GDPR references $basePath = base_path("references/gdpr/{$platform}"); // Find the most recent date folder $dateFolders = File::isDirectory($basePath) ? File::directories($basePath) : []; if (empty($dateFolders)) { abort(404, 'Privacy policy not found'); } // Sort folders by name (dates in YYYY-MM-DD format) descending rsort($dateFolders); $latestFolder = $dateFolders[0]; // Construct the file path $fileName = "privacy-policy-FULL-{$locale}.md"; $filePath = "{$latestFolder}/{$fileName}"; if (!File::exists($filePath)) { abort(404, 'Privacy policy not found for this language'); } // Return the file as a download return response()->download($filePath, $fileName, [ 'Content-Type' => 'text/markdown', ]); } }