@php
//set array up before loop so it doesn't get wiped at every iteration
$fields = [];
@endphp
@foreach($models as $model)
@if (($model) && ($model->fieldset))
@foreach($model->fieldset->fields AS $field)
@php
//prevents some duplicate queries - open to a better way of skipping dupes in output
//its ugly, but if we'd rather deal with duplicate queries we can get rid of this.
if (in_array($field->db_column_name(), $fields)) {
$duplicate = true;
continue;
} else {
$duplicate = false;
}
$fields[] = $field->db_column_name();
@endphp