Файловый менеджер - Редактировать - /home/clickysoft/public_html/travel-guru.clickysoft.net/app/Rules/HighlightRules.php
Назад
<?php namespace App\Rules; use Closure; use Illuminate\Contracts\Validation\ValidationRule; class HighlightRules implements ValidationRule { /** * Run the validation rule. * * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail */ public function validate(string $attribute, mixed $value, Closure $fail): void { $totalNonNullValues = 0; foreach ($value as $key => $highlight) { if ($key != 0 && !empty($highlight['value'])) { $totalNonNullValues++; } } $jsonAtIndex0 = json_decode($value[0], true); $totalValuesAtIndex0 = is_array($jsonAtIndex0) ? count($jsonAtIndex0) : 0; $total = $totalNonNullValues + $totalValuesAtIndex0; if ($total === 0) { $fail('Please select at least one highlights.'); } if ($total > 6) { $fail('Highlights must not exceed 6.'); } } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка