diff --git a/app/Http/Controllers/Admin/Authority/RoleTranslationsController.php b/app/Http/Controllers/Admin/Authority/RoleTranslationsController.php
index 01400f5f8..e42a9c327 100644
--- a/app/Http/Controllers/Admin/Authority/RoleTranslationsController.php
+++ b/app/Http/Controllers/Admin/Authority/RoleTranslationsController.php
@@ -6,12 +6,49 @@
use App\Http\Controllers\Controller;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Lang;
+use League\Csv\Writer;
class RoleTranslationsController extends Controller
{
public function index()
{
- $translations = Authority::query()
+ $translations = $this->getTranslations();
+
+ $missingCount = $translations->reduce(function (int $carry, $translations) {
+ if ($translations->sk === null) {
+ $carry++;
+ }
+ if ($translations->cs === null) {
+ $carry++;
+ }
+ if ($translations->en === null) {
+ $carry++;
+ }
+ return $carry;
+ }, 0);
+
+ return view('authorities.role-translations.index', compact('translations', 'missingCount'));
+ }
+
+ public function download()
+ {
+ $csv = Writer::createFromString();
+ $csv->insertOne(['id', 'sk', 'cs', 'en']);
+
+ $rows = $this->getTranslations()
+ ->map(fn($t) => [$t->id, $t->sk, $t->cs, $t->en])
+ ->toArray();
+
+ $csv->insertAll($rows);
+
+ return response($csv->toString())
+ ->header('Content-Type', 'text/csv')
+ ->header('Content-Disposition', 'attachment; filename=role_translations.csv');
+ }
+
+ private function getTranslations()
+ {
+ return Authority::query()
->select('roles')
->whereNotNull('roles')
->distinct()
@@ -33,20 +70,5 @@ public function index()
: null,
];
});
-
- $missingCount = $translations->reduce(function (int $carry, $translations) {
- if ($translations->sk === null) {
- $carry++;
- }
- if ($translations->cs === null) {
- $carry++;
- }
- if ($translations->en === null) {
- $carry++;
- }
- return $carry;
- }, 0);
-
- return view('authorities.role_translations.index', compact('translations', 'missingCount'));
}
}
diff --git a/resources/views/authorities/role_translations/index.blade.php b/resources/views/authorities/role-translations/index.blade.php
similarity index 96%
rename from resources/views/authorities/role_translations/index.blade.php
rename to resources/views/authorities/role-translations/index.blade.php
index 504810452..275e68a90 100644
--- a/resources/views/authorities/role_translations/index.blade.php
+++ b/resources/views/authorities/role-translations/index.blade.php
@@ -31,9 +31,9 @@
@endif
- {{--