dark_mode; } /** * Recursively expand validation rules * * @param $arr * @return array */ function vali($arr) { $result = []; foreach ($arr as $key => $rules) { // top level if (is_array($rules)) { $ar = []; foreach ($rules as $rule) { if (is_string($rule) && strpos($rule, '|') !== false) { foreach (explode('|', $rule) as $rr) { $ar[] = $rr; } } else if (is_array($rule)) { // nested array, assume no further recursion foreach ($rule as $rr) { $ar[] = $rr; } } else { // Rule $ar[] = $rule; } } $result[$key] = $ar; } else { // string or Rule $result[$key] = $rules; } } return $result; } /** * like old(), but decodes stringified json * * @param string $name * @param object|array $default * @return object|array */ function old_json($name, $default) { $old = old($name, null); if (is_string($old)) return json_decode($old); return $default; } // Safe JSON funcs function toJSON($object) { return \GuzzleHttp\json_encode($object, JSON_UNESCAPED_SLASHES + JSON_UNESCAPED_UNICODE); } function fromJSON($object, $assoc=false) { return \GuzzleHttp\json_decode($object, $assoc); }