has_payment) || !class_exists('FluentForm\\App\\Modules\\Form\\FormFieldsParser')) { return []; } try { $inputs = \FluentForm\App\Modules\Form\FormFieldsParser::getInputsByElementTypes($form, ['input_text', 'textarea', 'input_email'], ['element', 'admin_label']); } catch (\Throwable $error) { return []; } if (!is_array($inputs)) { return []; } $fields = []; foreach ($inputs as $key => $input) { if (!is_string($key) || !preg_match('/^[a-zA-Z0-9_-]{1,100}$/', $key) || !is_array($input) || !in_array($input['element'] ?? '', ['input_text', 'textarea', 'input_email'], true)) { continue; } $fields[$key] = is_string($input['admin_label'] ?? null) && $input['admin_label'] !== '' ? $input['admin_label'] : $key; } return $fields; } public static function available(int $limit): array { if ($limit < 1 || !class_exists('FluentForm\\App\\Models\\Form')) { return []; } try { $forms = \FluentForm\App\Models\Form::where('has_payment', 0)->orderBy('id', 'ASC')->limit($limit)->get(); $available = []; foreach ($forms as $form) { $fields = self::fields($form); if ($fields && (int) $form->id > 0) { $available['fluentform_' . (int) $form->id] = ['title' => 'Fluent Forms:' . (string) $form->title, 'fields' => $fields]; } } return $available; } catch (\Throwable $error) { return []; } } }