File manager - Edit - /var/www/html/spdc/api/app/Rules/ArrayInput.php
Back
<?php namespace App\Rules; use Illuminate\Contracts\Validation\InvokableRule; class ArrayInput implements InvokableRule { /** * Run the validation rule. * * @param string $attribute * @param mixed $value * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail * @return void */ public function __invoke($attribute, $value, $fail) { if (is_string($value)) { /** * cheking if is a valid json as a string */ $items = json_decode($value); /** * if not, checking if it is items separated by comma. Ex.: banana, orange, tomato */ if (is_null($items)) { $items = explode(",", $value); } if (!is_array($items)) { $fail('The :attribute must be an array.'); } } } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings