Skip to content

Commit 9d397e6

Browse files
Fixes module generator template issues
Corrects issues in the module generator templates, specifically addressing inconsistencies in route generation and parameter handling for the update and delete functions. Ensures that the generated routes use the correct module name and that the update and delete methods in the generated controller use the correct variable type for the id parameter.
1 parent b05407c commit 9d397e6

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/Commands/ModuleGenerator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function createModuleStructure($modulePath, $moduleName)
5151
$this->createFile($modulePath . '/Controllers/' . $moduleName . '.php', $this->getControllerTemplate($moduleName));
5252
$this->createFile($modulePath . '/Language/en/' . $moduleName . '.php', $this->getLanguageTemplate($moduleName, 'en'));
5353
$this->createFile($modulePath . '/Language/tr/' . $moduleName . '.php', $this->getLanguageTemplate($moduleName, 'tr'));
54-
54+
5555
$this->createFile($modulePath . '/Views/create.php', $this->getViewTemplate('<a href="'.route_to(lcfirst($moduleName)).'" class="btn btn-outline-info">'.lang('Backend.backToList').'</a>'));
5656
$this->createFile($modulePath . '/Views/list.php', $this->getViewTemplate('<a href="'.route_to(lcfirst($moduleName).'Create').'" class="btn btn-outline-success">'.lang('Backend.add').'</a>'));
5757
$this->createFile($modulePath . '/Views/update.php', $this->getViewTemplate('<a href="'.route_to(lcfirst($moduleName)).'" class="btn btn-outline-info">'.lang('Backend.backToList').'</a>'));
@@ -95,7 +95,7 @@ protected function getRoutesTemplate($moduleName)
9595
\$routes->match(['GET', 'POST'], '/', '{$moduleName}::index',['as' => '{$l_moduleName}', 'role' => 'read']);
9696
\$routes->match(['GET', 'POST'], 'create', '{$moduleName}::create', ['as' => '{$l_moduleName}Create', 'role' => 'create']);
9797
\$routes->match(['GET', 'POST'], 'update/(:num)', '{$moduleName}::update/$1', ['as' => '{$l_moduleName}Update', 'role' => 'update']);
98-
\$routes->get('delete', '{$modulesName}::delete(:num)',['as' => '{$l_moduleName}Delete/$1', 'role' => 'delete']);
98+
\$routes->get('delete', '{$moduleName}::delete(:num)',['as' => '{$l_moduleName}Delete/$1', 'role' => 'delete']);
9999
});
100100
EOD;
101101
}
@@ -154,7 +154,7 @@ public function create() {
154154
return view('Modules\\{$moduleName}\\Views\create', \$this->defData);
155155
}
156156
157-
public function update(int $id) {
157+
public function update(int \$id) {
158158
if (\$this->request->is('post')) {
159159
\$vdata = [
160160
''=>['label'=>'', 'rules'=>''],
@@ -165,7 +165,7 @@ public function update(int $id) {
165165
return view('Modules\\{$moduleName}\\Views\update', \$this->defData);
166166
}
167167
168-
public function delete(int $id)
168+
public function delete(int \$id)
169169
{
170170
\$infos=\$this->commonModel->selectOne('your_table',['id'=>\$id]);
171171
if(\$this->commonModel->remove('your_table',['id'=>\$id]))

0 commit comments

Comments
 (0)