private function buildTable()
{
$used = [];
$headings = '';
$columns = '';
foreach ($this->fields as $field) {
// Check if there is no duplication for radio and checkbox.
// Password fields are excluded from the table too.
if (!in_array($field->title, $used) && $field->type != 'password' && $field->type != 'textarea' && $field->show == 1) {
$headings .= "<th>{$field->label}</th>\r\n";
// Format our table column by field type
if ($field->type == 'relationship') {
$columns .= '<td>{{ isset($row->' . $field->relationship_name . '->' . $field->relationship_field . ') ? $row->' . $field->relationship_name . '->' . $field->relationship_field . " : '' }}</td>\r\n";
$used[$field->relationship_field] = $field->relationship_field;
} elseif ($field->type == 'photo') {
$columns .= '<td>@if($row->' . $field->title . ' != \'\')<img src="{{ asset(\'uploads/thumb\') . \'/\'. $row->' . $field->title . " }}\">@endif</td>\r\n";
$used[$field->title] = $field->title;
} else {
$columns .= '<td>{{ $row->' . $field->title . " }}</td>\r\n";
$used[$field->title] = $field->title;
}
}
}
$this->headings = $headings;
$this->columns = $columns;
}