26 lines
664 B
PHP
26 lines
664 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Concerns;
|
|
|
|
use App\Services\ContentModerationService;
|
|
use Illuminate\Contracts\Validation\Validator;
|
|
|
|
trait ModeratesUserContent
|
|
{
|
|
/**
|
|
* @param array<int, mixed> $texts
|
|
* @param array<int, mixed> $images
|
|
* @return array<int, callable>
|
|
*/
|
|
protected function moderationChecks(array $texts, array $images = []): array
|
|
{
|
|
return [function (Validator $validator) use ($texts, $images): void {
|
|
if ($validator->errors()->isNotEmpty()) {
|
|
return;
|
|
}
|
|
|
|
app(ContentModerationService::class)->ensureAcceptable($texts, $images);
|
|
}];
|
|
}
|
|
}
|