|
@@ -52,6 +52,11 @@ class GenerateTreeCommand extends Command
|
|
|
|
|
|
foreach ($lines as $line) {
|
|
foreach ($lines as $line) {
|
|
|
|
|
|
|
|
+ // stop (debugging)
|
|
|
|
+ if(trim($line) === '##stop') {
|
|
|
|
+ exit(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
// skip comments
|
|
// skip comments
|
|
if(trim($line)[0] === '#') continue;
|
|
if(trim($line)[0] === '#') continue;
|
|
|
|
|
|
@@ -468,9 +473,20 @@ class GenController {
|
|
$loadingLine[] = "->where('{$this->condition['field']}', {$this->condition['value']})";
|
|
$loadingLine[] = "->where('{$this->condition['field']}', {$this->condition['value']})";
|
|
}
|
|
}
|
|
$loadingLine[] = "->get();";
|
|
$loadingLine[] = "->get();";
|
|
|
|
+ $input[] = "'records'";
|
|
$code[] = implode("", $loadingLine);
|
|
$code[] = implode("", $loadingLine);
|
|
|
|
+
|
|
|
|
+ foreach ($method->queries as $key => $query) {
|
|
|
|
+ // replace $x with " . ($record->x ? $record->x : "''") . "
|
|
|
|
+ $query = preg_replace("/([^$])\\$([a-zA-Z0-9_]+)/", "$1\" . (\$record->$2 ? \$record->$2 : \"''\") . \"", $query);
|
|
|
|
+ // replace $$x with " . ($subRecord->x ? $subRecord->x : "''") . "
|
|
|
|
+ $query = preg_replace("/\\$\\$([a-zA-Z0-9_]+)/", "\" . (\$subRecord->$1 ? \$subRecord->$1 : \"''\") . \"", $query);
|
|
|
|
+ $code[] = "\t\t\$result_$key = DB::select(\"$query\");";
|
|
|
|
+ $input[] = "'result_$key'";
|
|
|
|
+ }
|
|
|
|
+
|
|
$code[] = "\t\treturn response()->view('{$this->root}/{$this->name}/{$method->name}', " .
|
|
$code[] = "\t\treturn response()->view('{$this->root}/{$this->name}/{$method->name}', " .
|
|
- "compact('records'), " .
|
|
|
|
|
|
+ "compact(" . implode(", ", $input) . "), " .
|
|
"session('message') ? 500 : 200)->header('Content-Type', 'text/html');";
|
|
"session('message') ? 500 : 200)->header('Content-Type', 'text/html');";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -569,6 +585,9 @@ class GenController {
|
|
"select(\"{$method->columns[$column]["query"]}\");\n" .
|
|
"select(\"{$method->columns[$column]["query"]}\");\n" .
|
|
"echo (\$_r && count(\$_r)) ? \$_r[0]->result : '-'; ?>";
|
|
"echo (\$_r && count(\$_r)) ? \$_r[0]->result : '-'; ?>";
|
|
}
|
|
}
|
|
|
|
+ else if(isset($method->columns[$column]["getter"])) {
|
|
|
|
+ $columnValue = $method->columns[$column]["getter"];
|
|
|
|
+ }
|
|
if(isset($method->columns[$column]["link"])) {
|
|
if(isset($method->columns[$column]["link"])) {
|
|
$hasLink = true;
|
|
$hasLink = true;
|
|
$linkTarget = $method->columns[$column]["link"];
|
|
$linkTarget = $method->columns[$column]["link"];
|
|
@@ -915,8 +934,10 @@ class GenController {
|
|
$this->w('Rout: ' . $method->route, 1);
|
|
$this->w('Rout: ' . $method->route, 1);
|
|
$this->w('Meth: ' . $method->name . '($request' . ($method->hasUID ? ', $uid' : '') . ')', 1);
|
|
$this->w('Meth: ' . $method->name . '($request' . ($method->hasUID ? ', $uid' : '') . ')', 1);
|
|
if(!empty($method->data)) $this->w('Data: ' . implode(", ", $method->data), 1);
|
|
if(!empty($method->data)) $this->w('Data: ' . implode(", ", $method->data), 1);
|
|
- $this->w('Exit: ' . $method->exitURL, 1);
|
|
|
|
- $this->w('View: ' . $method->viewURL, 1);
|
|
|
|
|
|
+// $this->w('Exit: ' . $method->exitURL, 1);
|
|
|
|
+// $this->w('View: ' . $method->viewURL, 1);
|
|
|
|
+ dump($method->columns);
|
|
|
|
+ dump($method->queries);
|
|
if(!$method->redirect) {
|
|
if(!$method->redirect) {
|
|
$this->w('View: ' . resource_path("views/{$this->root}/{$this->name}/{$method->name}.blade.php"), 1);
|
|
$this->w('View: ' . resource_path("views/{$this->root}/{$this->name}/{$method->name}.blade.php"), 1);
|
|
}
|
|
}
|
|
@@ -1018,8 +1039,14 @@ class GenController {
|
|
($required ? "required" : "") .
|
|
($required ? "required" : "") .
|
|
">";
|
|
">";
|
|
$code[] = "<option value=''>-- Select --</option>";
|
|
$code[] = "<option value=''>-- Select --</option>";
|
|
- $code[] = "<?php \$dbOptions = \Illuminate\Support\Facades\DB::table('{$options['table']}')->get(); ?>";
|
|
|
|
- $code[] = "<?php foreach(\$dbOptions as \$o): ?>";
|
|
|
|
|
|
+ if($options['table'][0] === '~') { // from named query
|
|
|
|
+ $code[] = "<?php foreach(\$result_" . substr($options['table'], 1) . " as \$o): ?>";
|
|
|
|
+ }
|
|
|
|
+ else { // select query
|
|
|
|
+ $code[] = "<?php \$dbOptions = \Illuminate\Support\Facades\DB::table('{$options['table']}')->get(); ?>";
|
|
|
|
+ $code[] = "<?php foreach(\$dbOptions as \$o): ?>";
|
|
|
|
+ }
|
|
|
|
+
|
|
$code[] = "<option " .
|
|
$code[] = "<option " .
|
|
"<?= \$o->{$options['valueField']} === (old('$name') ? old('$name') : " . ($default ? "\$record->$default" : "''") . ") ? 'selected' : '' ?> " .
|
|
"<?= \$o->{$options['valueField']} === (old('$name') ? old('$name') : " . ($default ? "\$record->$default" : "''") . ") ? 'selected' : '' ?> " .
|
|
"value='<?= \$o->{$options['valueField']} ?>'><?= \$o->{$options['displayField']} ?> (<?= \$o->{$options['valueField']} ?>)</option>";
|
|
"value='<?= \$o->{$options['valueField']} ?>'><?= \$o->{$options['displayField']} ?> (<?= \$o->{$options['valueField']} ?>)</option>";
|