@@ -9,7 +9,7 @@ |
||
9 | 9 | { |
10 | 10 | |
11 | 11 | /** @test */ |
12 | - public function test_is_working(){ |
|
12 | + public function test_is_working() { |
|
13 | 13 | $this->assertTrue(True); |
14 | 14 | } |
15 | 15 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public static function getFilesFromStubs($fileName) |
16 | 16 | { |
17 | - return __DIR__ . "/../Stubs/$fileName.stub"; |
|
17 | + return __DIR__."/../Stubs/$fileName.stub"; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public static function getFilesFromStubsAsStream($fileName) |
25 | 25 | { |
26 | - return File::get(__DIR__ . "/../Stubs/$fileName.stub"); |
|
26 | + return File::get(__DIR__."/../Stubs/$fileName.stub"); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | // model area |
90 | 90 | $fillable = []; |
91 | 91 | $protectedFillable = ""; |
92 | - $databaseColumn = '$table->id();' . "\n"; |
|
92 | + $databaseColumn = '$table->id();'."\n"; |
|
93 | 93 | // we build here fillabel for model and column for migration file at once. |
94 | 94 | foreach ($columns as $name => $item) { |
95 | 95 | // build fillabe property in model. |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | // get column type. |
98 | 98 | $type = array_key_first($item['type']); |
99 | 99 | // put this column as this ex : $table->string('name'). |
100 | - $databaseColumn .= '$table->' . "$type('$name'); \n"; |
|
100 | + $databaseColumn .= '$table->'."$type('$name'); \n"; |
|
101 | 101 | } |
102 | 102 | $imp = implode(",", $fillable); |
103 | - $protectedFillable .= 'protected $fillable = ' . " [$imp];"; |
|
103 | + $protectedFillable .= 'protected $fillable = '." [$imp];"; |
|
104 | 104 | $this->replacement("//", $protectedFillable, $options["file"], $options["path"]); |
105 | 105 | // check if user choose to build migration. |
106 | 106 | if (isset($options['migrationRequired'])) { |
@@ -91,7 +91,9 @@ |
||
91 | 91 | */ |
92 | 92 | protected function classReplacer($option) |
93 | 93 | { |
94 | - if (!gettype($option) == 'array') $option = [$option]; |
|
94 | + if (!gettype($option) == 'array') { |
|
95 | + $option = [$option]; |
|
96 | + } |
|
95 | 97 | $this->paths = array_intersect_key($this->paths, $option); |
96 | 98 | foreach ($option as $path => $classNameSpace) { |
97 | 99 | $className = $this->getCLassName($classNameSpace); |
@@ -9,14 +9,14 @@ discard block |
||
9 | 9 | class ApisGeneratorServiceProviders extends ServiceProvider |
10 | 10 | { |
11 | 11 | |
12 | - public function boot(){ |
|
12 | + public function boot() { |
|
13 | 13 | $this->registerFacades(); |
14 | 14 | $this->publishesPackages(); |
15 | 15 | $this->loadResource(); |
16 | 16 | |
17 | 17 | } |
18 | 18 | |
19 | - public function register(){ |
|
19 | + public function register() { |
|
20 | 20 | $this->commands([ |
21 | 21 | TestCommands::class |
22 | 22 | ]); |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | |
30 | 30 | protected function registerFacades() |
31 | 31 | { |
32 | - $this->app->singleton("KMFileHelper" , function ($app){ |
|
32 | + $this->app->singleton("KMFileHelper", function($app) { |
|
33 | 33 | return new KMFileHelper(); |
34 | 34 | }); |
35 | - $this->app->singleton("ApisGeneratorRoutes" , function ($app){ |
|
35 | + $this->app->singleton("ApisGeneratorRoutes", function($app) { |
|
36 | 36 | return new ApisGeneratorRoutes(); |
37 | 37 | }); |
38 | 38 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $cssPath = "ApisGenerator/css"; |
45 | 45 | $this->publishes([ |
46 | 46 | __DIR__."/../Config/apis_generator.php" => config_path("apis_generator.php") |
47 | - ] , "apis-generator-config"); |
|
47 | + ], "apis-generator-config"); |
|
48 | 48 | |
49 | 49 | $this->publishes([ |
50 | 50 | $asset."create.blade.php" => resource_path("$views/create.blade.php"), |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $asset."_layouts.blade.php" => resource_path("$views/layouts/_layouts.blade.php"), |
54 | 54 | $asset."script.js" => public_path("$scriptPath/script.js"), |
55 | 55 | $asset."css.css" => public_path("$cssPath/css.css"), |
56 | - ] , "apis-generator-asset"); |
|
56 | + ], "apis-generator-asset"); |
|
57 | 57 | |
58 | 58 | } |
59 | 59 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function initialRequest($request): GeneratorService |
52 | 52 | { |
53 | - [$this->request , $this->column , $this->apiTitle ] = [$request , $request->column , $request->title]; |
|
53 | + [$this->request, $this->column, $this->apiTitle] = [$request, $request->column, $request->title]; |
|
54 | 54 | // append all basic options that actor want to run migration to new array |
55 | 55 | foreach ($this->request->basic_options as $item => $status) { |
56 | 56 | $this->basicBuildOption [] = $item; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $this->setBaseControllerExists(); |
84 | 84 | // merge basic options and advanced options. |
85 | 85 | //we here want to be advanced options last options to run inside foreach. |
86 | - $options = array_merge($this->basicBuildOption , $this->advancedBuildOption); |
|
86 | + $options = array_merge($this->basicBuildOption, $this->advancedBuildOption); |
|
87 | 87 | foreach ($options as $option) { |
88 | 88 | if (method_exists(__CLASS__, $option)) { |
89 | 89 | $this->$option(); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | $builder = new KMModelAndMigrationBuilder(); |
108 | 108 | $modelClass = "$this->apiTitle"; |
109 | - $migrationRequired = in_array("buildMigration" , $this->basicBuildOption) ? "-m" : ""; |
|
109 | + $migrationRequired = in_array("buildMigration", $this->basicBuildOption) ? "-m" : ""; |
|
110 | 110 | $builder->initialResource($modelClass, "modelAndMigrationReplacer") |
111 | 111 | ->callArtisan($migrationRequired) |
112 | 112 | ->build($this->column, ["migrationRequired" => $migrationRequired]); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | protected function buildRequests() |
148 | 148 | { |
149 | 149 | $builder = new KMRequestBuilder(); |
150 | - $requestClass = "$this->apiTitle" . "Request"; |
|
150 | + $requestClass = "$this->apiTitle"."Request"; |
|
151 | 151 | $builder->initialResource($requestClass, "requestReplacer") |
152 | 152 | ->callArtisan() |
153 | 153 | ->build($this->column); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | protected function buildController() |
169 | 169 | { |
170 | 170 | $builder = new KMControllerBuilder(); |
171 | - $controllerClass = "$this->apiTitle" . "Controller"; |
|
171 | + $controllerClass = "$this->apiTitle"."Controller"; |
|
172 | 172 | $controllerBuildType = !$this->baseControllerExists ? "basicBuild" : "build"; |
173 | 173 | return $builder->initialResource($controllerClass, "controllerReplacer") |
174 | 174 | ->callArtisan() |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | */ |
184 | 184 | protected function buildResource() |
185 | 185 | { |
186 | - Artisan::call("make:resource " . "$this->apiTitle" . "Resource"); |
|
187 | - return $this->paths["{{ resource_path }}"] = KMFileHelper::getClassNameSpace("Resources", "$this->apiTitle" . "Resource"); |
|
186 | + Artisan::call("make:resource "."$this->apiTitle"."Resource"); |
|
187 | + return $this->paths["{{ resource_path }}"] = KMFileHelper::getClassNameSpace("Resources", "$this->apiTitle"."Resource"); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | { |
200 | 200 | $data = [ |
201 | 201 | "title" => $this->apiTitle, |
202 | - "route" => "$this->apiTitle" . "Controller", |
|
202 | + "route" => "$this->apiTitle"."Controller", |
|
203 | 203 | "url" => "$this->apiTitle", |
204 | 204 | "name" => "$this->apiTitle", |
205 | 205 | "type" => "resource", |
@@ -18,8 +18,8 @@ |
||
18 | 18 | public function create(ApisGeneratorRequest $request) |
19 | 19 | { |
20 | 20 | $this->generatorService->initialRequest($request)->generateApi(); |
21 | - session()->flash('alert_type' , 'success'); |
|
22 | - session()->flash('success' , 'create new api successfully'); |
|
21 | + session()->flash('alert_type', 'success'); |
|
22 | + session()->flash('success', 'create new api successfully'); |
|
23 | 23 | return redirect()->route('apisGenerator.index'); |
24 | 24 | } |
25 | 25 | } |
@@ -9,9 +9,9 @@ |
||
9 | 9 | { |
10 | 10 | public static function getRoutes() |
11 | 11 | { |
12 | - return Route::group([], function () { |
|
12 | + return Route::group([], function() { |
|
13 | 13 | $extraRoutes = KMFileHelper::getCredentialJsonFileAsJson(); |
14 | - if (isset($extraRoutes)){ |
|
14 | + if (isset($extraRoutes)) { |
|
15 | 15 | foreach ($extraRoutes as $api) { |
16 | 16 | if (isset($api->route) && isset($api->url)) { |
17 | 17 | Route::apiResource($api->url, $api->route); |
@@ -4,12 +4,12 @@ |
||
4 | 4 | |
5 | 5 | Route::namespace("KMLaravel\ApiGenerator\Controllers") |
6 | 6 | ->middleware(['web']) |
7 | - ->group(function () { |
|
8 | - Route::group([], function () { |
|
9 | - Route::get('/apis-generator/index', function () { |
|
7 | + ->group(function() { |
|
8 | + Route::group([], function() { |
|
9 | + Route::get('/apis-generator/index', function() { |
|
10 | 10 | return view('ApisGenerator/index'); |
11 | 11 | })->name('apisGenerator.index'); |
12 | - Route::get('/apis-generator/create', function () { |
|
12 | + Route::get('/apis-generator/create', function() { |
|
13 | 13 | return view('ApisGenerator/create'); |
14 | 14 | })->name('apisGenerator.create'); |
15 | 15 | Route::post('/apis-generator/create', "ApisGeneratorController@create") |