|
@@ -339,18 +339,41 @@ class GenController {
|
|
|
$input = ["'record'"];
|
|
|
// if sub-index controller, load subRecords
|
|
|
if($method->type === 'sub' && count($method->data)) {
|
|
|
- $dbParts = explode("=", $method->data[0]);
|
|
|
+ $parts = explode(",", $method->data[0]);
|
|
|
+
|
|
|
+ $loadingLine = [];
|
|
|
+
|
|
|
+ // first 'where'
|
|
|
+ $dbParts = explode("=", $parts[0]);
|
|
|
$localField = $dbParts[0];
|
|
|
$dbParts = explode(".", $dbParts[1]);
|
|
|
$foreignTable = $dbParts[0];
|
|
|
$foreignField = $dbParts[1];
|
|
|
- $code[] = "\t\t\$subRecords = DB::table('$foreignTable')->where('$foreignField', \$record->$localField)->get();";
|
|
|
+ $loadingLine[] = "\t\t\$subRecords = DB::table('$foreignTable')";
|
|
|
+ $loadingLine[] = "->where('$foreignField', \$record->$localField)";
|
|
|
+
|
|
|
+ // other 'where's
|
|
|
+ if(count($parts) > 1) {
|
|
|
+ for ($i = 1; $i < count($parts); $i++) {
|
|
|
+ $dbParts = explode("=", $parts[$i]);
|
|
|
+ $field = $dbParts[0];
|
|
|
+ $value = $dbParts[1];
|
|
|
+ $loadingLine[] = "->where('$field', $value)";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $loadingLine[] = "->get();";
|
|
|
+
|
|
|
+ $code[] = implode("", $loadingLine);
|
|
|
+
|
|
|
+ // $code[] = "\t\t\$subRecords = DB::table('$foreignTable')->where('$foreignField', \$record->$localField)->get();";
|
|
|
$input[] = "'subRecords'";
|
|
|
}
|
|
|
$code[] = "\t\treturn view('{$this->root}/{$this->name}/{$method->name}', " .
|
|
|
"compact(" . implode(", ", $input) . "));";
|
|
|
}
|
|
|
else {
|
|
|
+ $loadingLine = [];
|
|
|
$loadingLine[] = "\t\t\$records = DB::table('{$this->dbTable}')";
|
|
|
if($this->condition) {
|
|
|
$loadingLine[] = "->where('{$this->condition['field']}', {$this->condition['value']})";
|
|
@@ -700,7 +723,7 @@ class GenController {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if($type !== 'hidden') {
|
|
|
+ if($type !== 'hidden' && $type !== 'bool') {
|
|
|
$code[] = "<div class='form-group mb-3'>";
|
|
|
$code[] = "<label class='control-label'>{$this->camelToTitleCase($this->snakeToTitleCase($display))}</label>";
|
|
|
}
|
|
@@ -729,9 +752,14 @@ class GenController {
|
|
|
$code[] = "<?php endforeach; ?>";
|
|
|
$code[] = "</select>";
|
|
|
break;
|
|
|
+ case "bool":
|
|
|
+ $code[] = "<div class='form-group mb-3'>";
|
|
|
+ $code[] = "<label class='control-label'>{$this->camelToTitleCase($this->snakeToTitleCase($display))} ";
|
|
|
+ $code[] = "<input class='form-control' type='checkbox' name='$name'>";
|
|
|
+ $code[] = "</label>";
|
|
|
+ break;
|
|
|
default:
|
|
|
- $code[] = "<input class='form-control' type='$type' name='$name' " . $valueLine .
|
|
|
- ">";
|
|
|
+ $code[] = "<input class='form-control' type='$type' name='$name' " . $valueLine . ">";
|
|
|
}
|
|
|
if($type !== 'hidden') {
|
|
|
$code[] = "</div>";
|