Skip to content

Commit ab578e2

Browse files
committed
changed structure
1 parent 31caecf commit ab578e2

File tree

8 files changed

+37
-35
lines changed

8 files changed

+37
-35
lines changed

src/Commands/ControllerMakeCommand.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ protected function getControllerName()
100100
{
101101
$controller = Str::studly($this->argument('controller'));
102102

103-
if (Str::contains(strtolower($controller), 'controller') === false) {
104-
$controller .= 'Controller';
105-
}
106-
107103
return $controller;
108104
}
109105

src/Commands/JobMakeCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,12 @@ protected function getTemplateContents()
6969
$module = $this->getModule();
7070

7171
return (new Stub($this->getStubName(), [
72-
'ALIAS' => $module->getAlias(),
73-
'NAMESPACE' => $this->getClassNamespace($module),
74-
'CLASS' => $this->getClass(),
72+
'ALIAS' => $module->getAlias(),
73+
'NAMESPACE' => $this->getClassNamespace($module),
74+
'CLASS' => $this->getClass(),
75+
'MODULE' => $this->getModuleName(),
76+
'NAME' => $this->getFileName(),
77+
'STUDLY_NAME' => $module->getStudlyName(),
7578
]))->render();
7679
}
7780

src/Commands/ProviderMakeCommand.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace Akaunting\Module\Commands;
44

5-
use Illuminate\Support\Str;
65
use Akaunting\Module\Module;
76
use Akaunting\Module\Support\Config\GenerateConfigReader;
87
use Akaunting\Module\Support\Stub;
98
use Akaunting\Module\Traits\ModuleCommandTrait;
9+
use Illuminate\Support\Str;
1010
use Symfony\Component\Console\Input\InputArgument;
1111
use Symfony\Component\Console\Input\InputOption;
1212

@@ -90,6 +90,13 @@ protected function getTemplateContents()
9090
'FACTORIES_PATH' => GenerateConfigReader::read('factory')->getPath(),
9191
]))->render();
9292
}
93+
/**
94+
* @return string
95+
*/
96+
private function getFileName()
97+
{
98+
return Str::studly($this->argument('name'));
99+
}
93100

94101
/**
95102
* @return mixed
@@ -103,11 +110,4 @@ protected function getDestinationFilePath()
103110
return $path . $generatorPath->getPath() . '/' . $this->getFileName() . '.php';
104111
}
105112

106-
/**
107-
* @return string
108-
*/
109-
private function getFileName()
110-
{
111-
return Str::studly($this->argument('name'));
112-
}
113113
}

src/Commands/RouteProviderMakeCommand.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,15 @@ protected function getTemplateContents()
5757
$module = $this->getModule();
5858

5959
return (new Stub('/route-provider.stub', [
60-
'ALIAS' => $module->getAlias(),
61-
'NAMESPACE' => $this->getClassNamespace($module),
62-
'CLASS' => $this->getFileName(),
63-
'MODULE_NAMESPACE' => $this->laravel['module']->config('namespace'),
64-
'MODULE' => $this->getModuleName(),
65-
'WEB_ROUTES_PATH' => $this->getWebRoutesPath(),
66-
'API_ROUTES_PATH' => $this->getApiRoutesPath(),
60+
'ALIAS' => $module->getAlias(),
61+
'NAMESPACE' => $this->getClassNamespace($module),
62+
'CLASS' => $this->getClass(),
63+
'MODULE' => $this->getModuleName(),
64+
'NAME' => $this->getFileName(),
65+
'STUDLY_NAME' => $module->getStudlyName(),
66+
'MODULE_NAMESPACE' => $this->laravel['module']->config('namespace'),
67+
'WEB_ROUTES_PATH' => $this->getWebRoutesPath(),
68+
'API_ROUTES_PATH' => $this->getApiRoutesPath(),
6769
]))->render();
6870
}
6971

@@ -72,7 +74,7 @@ protected function getTemplateContents()
7274
*/
7375
private function getFileName()
7476
{
75-
return 'RouteServiceProvider';
77+
return 'Route';
7678
}
7779

7880
/**

src/Commands/stubs/json.stub

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"active": 1,
66
"order": 0,
77
"providers": [
8-
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\$STUDLY_NAME$ServiceProvider"
8+
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\Main",
9+
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\Route"
910
],
1011
"aliases": {},
1112
"files": [],

src/Commands/stubs/route-provider.stub

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace $NAMESPACE$;
44

5-
use Illuminate\Support\Facades\Route;
6-
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
5+
use Illuminate\Support\Facades\Route as Facade;
6+
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as Provider;
77

8-
class $CLASS$ extends ServiceProvider
8+
class $NAME$ extends Provider
99
{
1010
/**
1111
* The module namespace to assume when generating URLs to actions.
@@ -47,9 +47,9 @@ class $CLASS$ extends ServiceProvider
4747
*/
4848
protected function mapWebRoutes()
4949
{
50-
Route::middleware('web')
50+
Facade::middleware('web')
5151
->namespace($this->moduleNamespace)
52-
->group(__DIR__ . '/../Routes/web.php');
52+
->group(__DIR__ . '/..$WEB_ROUTES_PATH$');
5353
}
5454

5555
/**
@@ -61,7 +61,7 @@ class $CLASS$ extends ServiceProvider
6161
*/
6262
protected function mapApiRoutes()
6363
{
64-
Route::prefix('api')
64+
Facade::prefix('api')
6565
->middleware('api')
6666
->namespace($this->moduleNamespace)
6767
->group(__DIR__ . '/..$API_ROUTES_PATH$');

src/Commands/stubs/scaffold/provider.stub

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace $NAMESPACE$;
44

5-
use Illuminate\Support\ServiceProvider;
5+
use Illuminate\Support\ServiceProvider as Provider;
66
use Illuminate\Database\Eloquent\Factory;
77

8-
class $CLASS$ extends ServiceProvider
8+
class $NAME$ extends Provider
99
{
1010
/**
1111
* Boot the application events.

src/Generators/ModuleGenerator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public function generateResources()
329329
]);
330330

331331
$this->console->call('module:make-provider', [
332-
'name' => $this->getName() . 'ServiceProvider',
332+
'name' => 'Main',
333333
'alias' => $this->alias,
334334
'--master' => true,
335335
]);
@@ -339,7 +339,7 @@ public function generateResources()
339339
]);
340340

341341
$this->console->call('module:make-controller', [
342-
'controller' => $this->getName() . 'Controller',
342+
'controller' => 'Main',
343343
'alias' => $this->alias,
344344
]);
345345
}
@@ -425,7 +425,7 @@ private function cleanModuleJsonFile()
425425
$namespace = $this->getModuleNamespaceReplacement();
426426
$studlyName = $this->getStudlyNameReplacement();
427427

428-
$provider = '"' . $namespace . '\\\\' . $studlyName . '\\\\Providers\\\\' . $studlyName . 'ServiceProvider"';
428+
$provider = '"' . $namespace . '\\\\' . $studlyName . '\\\\Providers\\\\' . $studlyName . '"';
429429

430430
$content = str_replace($provider, '', $content);
431431

0 commit comments

Comments
 (0)