field-details.blade.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <b><code>{{ $name }}</code></b>&nbsp;&nbsp;@if($type)<small>{{ $type }}</small>@endif @if(!$required)
  2. <i>optional</i>@endif &nbsp;
  3. @if(($isInput ?? true) && empty($hasChildren))
  4. @php
  5. $isList = Str::endsWith($type, '[]');
  6. $fullName =str_replace('[]', '.0', $name);
  7. $baseType = $isList ? substr($type, 0, -2) : $type;
  8. // Ignore the first '[]': the frontend will take care of it
  9. while (\Str::endsWith($baseType, '[]')) {
  10. $fullName .= '.0';
  11. $baseType = substr($baseType, 0, -2);
  12. }
  13. switch($baseType) {
  14. case 'number':
  15. case 'integer':
  16. $inputType = 'number';
  17. break;
  18. case 'file':
  19. $inputType = 'file';
  20. break;
  21. default:
  22. $inputType = 'text';
  23. }
  24. @endphp
  25. @if($type === 'boolean')
  26. <label data-endpoint="{{ $endpointId }}" hidden><input type="radio" name="{{ $fullName }}" value="{{$component === 'body' ? 'true' : 1}}" data-endpoint="{{ $endpointId }}" data-component="{{ $component }}" @if($required)required @endif><code>true</code></label>
  27. <label data-endpoint="{{ $endpointId }}" hidden><input type="radio" name="{{ $fullName }}" value="{{$component === 'body' ? 'false' : 0}}" data-endpoint="{{ $endpointId }}" data-component="{{ $component }}" @if($required)required @endif><code>false</code></label>
  28. @elseif($isList)
  29. <input type="{{ $inputType }}" name="{{ $fullName.".0" }}" data-endpoint="{{ $endpointId }}" data-component="{{ $component }}" @if($required)required @endif hidden>
  30. <input type="{{ $inputType }}" name="{{ $fullName.".1" }}" data-endpoint="{{ $endpointId }}" data-component="{{ $component }}" hidden>
  31. @else
  32. <input type="{{ $inputType }}" name="{{ $fullName }}" data-endpoint="{{ $endpointId }}" data-component="{{ $component }}" @if($required)required @endif hidden>
  33. @endif
  34. @endif
  35. <br>
  36. {!! Parsedown::instance()->text($description) !!}