private function addColumn($field, $type = "migration", $meta = "")
{
if ($type == 'migration') {
$syntax = sprintf("\$table->%s('%s')", $field['type'], $field['name']);
// If there are arguments for the schema type, like decimal('amount', 5, 2)
// then we have to remember to work those in.
if ($field['arguments']) {
$syntax = substr($syntax, 0, -1) . ', ';
$syntax .= implode(', ', $field['arguments']) . ')';
}
foreach ($field['options'] as $method => $value) {
$syntax .= sprintf("->%s(%s)", $method, $value === true ? '' : $value);
}
$syntax .= ';';
} elseif ($type == 'view-index-header') {
// Fields to index view
$syntax = sprintf("<th>%s", strtoupper($field['name']));
$syntax .= '</th>';
} elseif ($type == 'view-index-content') {
// Fields to index view
$syntax = sprintf("<td>{{\$%s->%s", $meta['var_name'], strtolower($field['name']));
$syntax .= '}}</td>';
} elseif ($type == 'view-show-content') {
// Fields to show view
$syntax = sprintf("<div class=\"form-group\">\n" . str_repeat(' ', 21) . "<label for=\"%s\">%s</label>\n" . str_repeat(' ', 21) . "<p class=\"form-control-static\">{{\$%s->%s}}</p>\n" . str_repeat(' ', 16) . "</div>", strtolower($field['name']), strtoupper($field['name']), $meta['var_name'], strtolower($field['name']));
} elseif ($type == 'view-edit-content') {
$syntax = $this->buildField($field, $type, $meta['var_name']);
} elseif ($type == 'view-create-content') {
$syntax = $this->buildField($field, $type, $meta['var_name'], false);
} else {
// Fields to controller
$syntax = sprintf("\$%s->%s = \$request->input(\"%s", $meta['var_name'], $field['name'], $field['name']);
$syntax .= '");';
}
return $syntax;
}