Initial commit: Pireon Admin — headless admin panel and public API
Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer collective, backed by the Pireon OAuth identity server. The public site is a separate, server-rendered application consuming /api/public/v1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
67
app/Support/Health/Checks/MissingTranslations.php
Normal file
67
app/Support/Health/Checks/MissingTranslations.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Support\Health\Checks;
|
||||
|
||||
use App\Filament\Resources\Pages\PageResource;
|
||||
use App\Models\Call;
|
||||
use App\Models\Page;
|
||||
use App\Models\Project;
|
||||
use App\Support\Health\Check;
|
||||
use App\Support\Health\Finding;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
/**
|
||||
* Published content with no title in one of the supported languages.
|
||||
*
|
||||
* The site does not break — the API simply omits that language from the
|
||||
* record's `alternates` — but a visitor browsing in Catalan finds the section
|
||||
* half empty and no one editing in Spanish ever sees it.
|
||||
*/
|
||||
class MissingTranslations implements Check
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'missing-translations';
|
||||
}
|
||||
|
||||
public function permission(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function run(): Finding
|
||||
{
|
||||
$locales = array_keys((array) config('locales.supported'));
|
||||
$count = 0;
|
||||
$samples = [];
|
||||
|
||||
foreach ([Page::class, Project::class, Call::class] as $model) {
|
||||
$records = $model::query()
|
||||
->when($model === Call::class, fn (Builder $q) => $q->open())
|
||||
->unless($model === Call::class, fn (Builder $q) => $q->published())
|
||||
->get(['id', 'title']);
|
||||
|
||||
foreach ($records as $record) {
|
||||
$missing = collect($locales)
|
||||
->reject(fn (string $locale) => filled($record->getTranslation('title', $locale, false)));
|
||||
|
||||
if ($missing->isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$count++;
|
||||
$samples[] = $record->getTranslation('title', (string) config('locales.default'), false)
|
||||
.' ('.$missing->implode(', ').')';
|
||||
}
|
||||
}
|
||||
|
||||
return Finding::problem(
|
||||
$this->key(),
|
||||
$count,
|
||||
url: PageResource::getUrl('index'),
|
||||
samples: $samples,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user