comparison 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
comparison
equal deleted inserted replaced
28:f88d2d5dee30 29:010ace248d14
87 } 87 }
88 88
89 protected function gatherRelations() { 89 protected function gatherRelations() {
90 $relations = RelationshipNavigator::getRelations($this->getCurrentTable()); 90 $relations = RelationshipNavigator::getRelations($this->getCurrentTable());
91 91
92 return renderRelations($relations); 92 return $relations;
93 93
94 } 94 }
95 95
96 protected function renderFilters() { 96 protected function renderFilters() {
97 $insert = ''; 97 $insert = '';
98 foreach ($this->get_columns() as $column) { 98 foreach ($this->get_columns() as $column) {
99 if (in_array($column['name'], $this->columns_to_ignore)) { 99 if (in_array($column['name'], $this->columns_to_ignore)) {
100 continue; 100 continue;
101 } 101 }
102 $insert .= sprintf("'%s',", $column['name'])."\n"; 102 $snippet = $this->getSnippet('filter');
103 } 103 $tableName = $this->getCurrentTable();
104 104 $value = 'value'; // TODO: this should be determined based on column type
105 $columnName = $column['name'];
106 $columnDisplay = Str::headline($columnName);
107
108 // Replace placeholders with actual values
109 $string = str_replace(
110 ['{{value}}', '{{columnDisplay}}', '{{tableName}}', '{{columnName}}'],
111 [$value, $columnDisplay, $tableName, $columnName],
112 $snippet
113 );
114 $insert .= sprintf("%s", $string);
115 }
116
117 return $insert;
105 } 118 }
106 119
107 protected function renderRelations($relations) { 120 protected function renderRelations($relations) {
108 $renders = [ 121 $renders = [
109 'belongsTo' => [], 122 'belongsTo' => [],