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>
52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\Health\Checks;
|
|
|
|
use App\Filament\Resources\Testimonials\TestimonialResource;
|
|
use App\Models\Testimonial;
|
|
use App\Support\Health\Check;
|
|
use App\Support\Health\Finding;
|
|
use App\Support\Health\Severity;
|
|
|
|
/**
|
|
* Quotes published without the words that were actually said.
|
|
*
|
|
* Every testimonial declares the language it was given in. When that language
|
|
* is the one field left empty, the site is publishing a translation of
|
|
* something nobody can check — which is the one way a testimonial stops being
|
|
* evidence and starts being copywriting.
|
|
*/
|
|
class TestimonialsMissingOriginal implements Check
|
|
{
|
|
public function key(): string
|
|
{
|
|
return 'testimonials-missing-original';
|
|
}
|
|
|
|
public function permission(): ?string
|
|
{
|
|
return 'testimonials.view_any';
|
|
}
|
|
|
|
public function run(): Finding
|
|
{
|
|
$offenders = Testimonial::query()
|
|
->public()
|
|
->get(['id', 'quote', 'original_locale', 'author_name'])
|
|
->filter(fn (Testimonial $t) => blank($t->getTranslation('quote', $t->original_locale, false)));
|
|
|
|
return Finding::problem(
|
|
$this->key(),
|
|
$offenders->count(),
|
|
Severity::Error,
|
|
url: TestimonialResource::getUrl('index'),
|
|
samples: $offenders
|
|
->map(fn (Testimonial $t) => $t->author_name.' ('.$t->original_locale.')')
|
|
->values()
|
|
->all(),
|
|
);
|
|
}
|
|
}
|