Mercurial > packages > magicforger
diff src/Generator/Model/ModelGenerator.php @ 29:010ace248d14 codex
Added support for filters, not fully there with relations or anything like that but it's a start
| author | Luka Sitas <sitas.luka.97@gmail.com> |
|---|---|
| date | Mon, 09 Jun 2025 20:51:04 -0400 |
| parents | f88d2d5dee30 |
| children |
line wrap: on
line diff
--- a/src/Generator/Model/ModelGenerator.php Mon Jun 09 19:51:31 2025 -0400 +++ b/src/Generator/Model/ModelGenerator.php Mon Jun 09 20:51:04 2025 -0400 @@ -89,7 +89,7 @@ protected function gatherRelations() { $relations = RelationshipNavigator::getRelations($this->getCurrentTable()); - return renderRelations($relations); + return $relations; } @@ -99,9 +99,22 @@ if (in_array($column['name'], $this->columns_to_ignore)) { continue; } - $insert .= sprintf("'%s',", $column['name'])."\n"; + $snippet = $this->getSnippet('filter'); + $tableName = $this->getCurrentTable(); + $value = 'value'; // TODO: this should be determined based on column type + $columnName = $column['name']; + $columnDisplay = Str::headline($columnName); + + // Replace placeholders with actual values + $string = str_replace( + ['{{value}}', '{{columnDisplay}}', '{{tableName}}', '{{columnName}}'], + [$value, $columnDisplay, $tableName, $columnName], + $snippet + ); + $insert .= sprintf("%s", $string); } + return $insert; } protected function renderRelations($relations) {
