@@ -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 | } |
@@ -18,6 +18,6 @@ |
||
18 | 18 | public function create(ApisGeneratorRequest $request) |
19 | 19 | { |
20 | 20 | $this->generatorService->initialRequest($request)->generateApi(); |
21 | - return redirect()->route('apisGenerator.index')->with('session_success' , 'create new api successfully'); |
|
21 | + return redirect()->route('apisGenerator.index')->with('session_success', 'create new api successfully'); |
|
22 | 22 | } |
23 | 23 | } |
@@ -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 | } |
21 | 21 | |
22 | 22 | /** |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | */ |
33 | 33 | protected function registerFacades() |
34 | 34 | { |
35 | - $this->app->singleton("KMFileFacade" , function ($app){ |
|
35 | + $this->app->singleton("KMFileFacade", function($app) { |
|
36 | 36 | return new KMFile(); |
37 | 37 | }); |
38 | - $this->app->singleton("KMRoutesFacade" , function ($app){ |
|
38 | + $this->app->singleton("KMRoutesFacade", function($app) { |
|
39 | 39 | return new KMRoutes(); |
40 | 40 | }); |
41 | - $this->app->singleton("KMFunctionsFacade" , function ($app){ |
|
41 | + $this->app->singleton("KMFunctionsFacade", function($app) { |
|
42 | 42 | return new KMFunctions(); |
43 | 43 | }); |
44 | 44 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $cssPath = "ApisGenerator/css"; |
55 | 55 | $this->publishes([ |
56 | 56 | __DIR__."/../Config/apis_generator.php" => config_path("apis_generator.php") |
57 | - ] , "apis-generator-config"); |
|
57 | + ], "apis-generator-config"); |
|
58 | 58 | |
59 | 59 | $this->publishes([ |
60 | 60 | $asset."create.blade.php" => resource_path("$views/create.blade.php"), |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $asset."_layouts.blade.php" => resource_path("$views/layouts/_layouts.blade.php"), |
64 | 64 | $asset."script.js" => public_path("$scriptPath/script.js"), |
65 | 65 | $asset."css.css" => public_path("$cssPath/css.css"), |
66 | - ] , "apis-generator-asset"); |
|
66 | + ], "apis-generator-asset"); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 |
@@ -4,16 +4,16 @@ |
||
4 | 4 | use KMLaravel\ApiGenerator\Facade\KMFunctionsFacade; |
5 | 5 | |
6 | 6 | Route::namespace("KMLaravel\ApiGenerator\Controllers") |
7 | - ->group(function () { |
|
7 | + ->group(function() { |
|
8 | 8 | // this is pull middleware information from apis_generator.php config file |
9 | - Route::group(['middleware' => array_merge(['web'], KMFunctionsFacade::getMiddleware() ?? [])], function () { |
|
10 | - Route::group([], function () { |
|
9 | + Route::group(['middleware' => array_merge(['web'], KMFunctionsFacade::getMiddleware() ?? [])], function() { |
|
10 | + Route::group([], function() { |
|
11 | 11 | // all apis table page |
12 | - Route::get('/apis-generator/index', function () { |
|
12 | + Route::get('/apis-generator/index', function() { |
|
13 | 13 | return view('ApisGenerator/index'); |
14 | 14 | })->name('apisGenerator.index'); |
15 | 15 | // create new api page |
16 | - Route::get('/apis-generator/create', function () { |
|
16 | + Route::get('/apis-generator/create', function() { |
|
17 | 17 | return view('ApisGenerator/create'); |
18 | 18 | })->name('apisGenerator.create'); |
19 | 19 | // post information route |
@@ -82,12 +82,12 @@ |
||
82 | 82 | protected function classReplacer($option) |
83 | 83 | { |
84 | 84 | if (!gettype($option) == 'array') $option = [$option]; |
85 | - $controllerNameSpace = $this->checkIfFileInSubFolder("App\Http\Controllers" , $this->fileName); |
|
85 | + $controllerNameSpace = $this->checkIfFileInSubFolder("App\Http\Controllers", $this->fileName); |
|
86 | 86 | $option['{{ controller_namespace }}'] = $controllerNameSpace; |
87 | 87 | foreach ($option as $path => $classNameSpace) { |
88 | 88 | $className = $this->getCLassName($classNameSpace); |
89 | - $classNameSpace = str_replace('/' , '\\' , $classNameSpace); |
|
90 | - $className = $this->array_last_value(explode('/' , $className)); |
|
89 | + $classNameSpace = str_replace('/', '\\', $classNameSpace); |
|
90 | + $className = $this->array_last_value(explode('/', $className)); |
|
91 | 91 | $this->paths[$path] = [ |
92 | 92 | $classNameSpace => $className, |
93 | 93 | ]; |
@@ -81,7 +81,9 @@ |
||
81 | 81 | */ |
82 | 82 | protected function classReplacer($option) |
83 | 83 | { |
84 | - if (!gettype($option) == 'array') $option = [$option]; |
|
84 | + if (!gettype($option) == 'array') { |
|
85 | + $option = [$option]; |
|
86 | + } |
|
85 | 87 | $controllerNameSpace = $this->checkIfFileInSubFolder("App\Http\Controllers" , $this->fileName); |
86 | 88 | $option['{{ controller_namespace }}'] = $controllerNameSpace; |
87 | 89 | foreach ($option as $path => $classNameSpace) { |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | $validation = []; |
102 | 102 | } |
103 | 103 | return $this->replacement( |
104 | - ["{{ request_namespace }}" , "{{ rules }}", "{{ request_class }}", "{{ request_auth }}"], |
|
104 | + ["{{ request_namespace }}", "{{ rules }}", "{{ request_class }}", "{{ request_auth }}"], |
|
105 | 105 | [ |
106 | - $this->checkIfFileInSubFolder("App\Http\Requests" , $this->fileName), |
|
106 | + $this->checkIfFileInSubFolder("App\Http\Requests", $this->fileName), |
|
107 | 107 | $validationRow, |
108 | 108 | $this->array_last_value(explode('/', $this->fileName)), |
109 | 109 | KMFunctionsFacade::getRequestAuthAccessibility() |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | // model area |
124 | 124 | $fillable = []; |
125 | 125 | $protectedFillable = ""; |
126 | - $databaseColumn = '$table->id();' . "\n"; |
|
126 | + $databaseColumn = '$table->id();'."\n"; |
|
127 | 127 | // we build here fillabel for model and column for migration file at once. |
128 | 128 | foreach ($columns as $name => $item) { |
129 | 129 | // build fillabe property in model. |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | // get column type. |
132 | 132 | $type = array_key_first($item['type']); |
133 | 133 | // put this column as this ex : $table->string('name'). |
134 | - $databaseColumn .= '$table->' . "$type('$name'); \n"; |
|
134 | + $databaseColumn .= '$table->'."$type('$name'); \n"; |
|
135 | 135 | } |
136 | 136 | $imp = implode(",", $fillable); |
137 | - $protectedFillable .= 'protected $fillable = ' . " [$imp];"; |
|
137 | + $protectedFillable .= 'protected $fillable = '." [$imp];"; |
|
138 | 138 | $this->replacement("//", $protectedFillable, $options["file"], $options["path"]); |
139 | 139 | // check if user choose to build migration. |
140 | 140 | if (isset($options['migrationRequired'])) { |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | * @param $fileName |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - protected function checkIfFileInSubFolder($initPath , $fileName){ |
|
224 | - $fileNameAsArray = explode('/' , $fileName); |
|
225 | - if (sizeof($fileNameAsArray) > 1) return $this->ImplodeNameSpace($initPath , $fileNameAsArray); |
|
223 | + protected function checkIfFileInSubFolder($initPath, $fileName) { |
|
224 | + $fileNameAsArray = explode('/', $fileName); |
|
225 | + if (sizeof($fileNameAsArray) > 1) return $this->ImplodeNameSpace($initPath, $fileNameAsArray); |
|
226 | 226 | return $initPath; |
227 | 227 | } |
228 | 228 | |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | * @param $fileNameAsArray |
232 | 232 | * @return string |
233 | 233 | */ |
234 | - protected function ImplodeNameSpace($initPath , $fileNameAsArray){ |
|
234 | + protected function ImplodeNameSpace($initPath, $fileNameAsArray) { |
|
235 | 235 | array_pop($fileNameAsArray); |
236 | - return "$initPath\\".implode('\\' , $fileNameAsArray); |
|
236 | + return "$initPath\\".implode('\\', $fileNameAsArray); |
|
237 | 237 | } |
238 | 238 | } |
@@ -222,7 +222,9 @@ |
||
222 | 222 | */ |
223 | 223 | protected function checkIfFileInSubFolder($initPath , $fileName){ |
224 | 224 | $fileNameAsArray = explode('/' , $fileName); |
225 | - if (sizeof($fileNameAsArray) > 1) return $this->ImplodeNameSpace($initPath , $fileNameAsArray); |
|
225 | + if (sizeof($fileNameAsArray) > 1) { |
|
226 | + return $this->ImplodeNameSpace($initPath , $fileNameAsArray); |
|
227 | + } |
|
226 | 228 | return $initPath; |
227 | 229 | } |
228 | 230 |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function initialRequest($request): GeneratorService |
54 | 54 | { |
55 | - [$this->request , $this->column , $this->apiTitle ] = [$request , $request->column , str_replace('\\' , '/' ,$request->title)]; |
|
55 | + [$this->request, $this->column, $this->apiTitle] = [$request, $request->column, str_replace('\\', '/', $request->title)]; |
|
56 | 56 | // append all basic options that actor want to run migration to new array |
57 | 57 | foreach ($this->request->basic_options as $item => $status) { |
58 | 58 | $this->basicBuildOption [] = $item; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $this->setBaseControllerExists(); |
86 | 86 | // merge basic options and advanced options. |
87 | 87 | //we here want to be advanced options last options to run inside foreach. |
88 | - $options = array_merge($this->basicBuildOption , $this->advancedBuildOption); |
|
88 | + $options = array_merge($this->basicBuildOption, $this->advancedBuildOption); |
|
89 | 89 | foreach ($options as $option) { |
90 | 90 | if (method_exists(__CLASS__, $option)) { |
91 | 91 | $this->$option(); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | { |
109 | 109 | $builder = new KMModelAndMigrationBuilder(); |
110 | 110 | $modelClass = "$this->apiTitle"; |
111 | - $migrationRequired = in_array("buildMigration" , $this->basicBuildOption) ? "-m" : ""; |
|
111 | + $migrationRequired = in_array("buildMigration", $this->basicBuildOption) ? "-m" : ""; |
|
112 | 112 | $builder->initialResource($modelClass, "modelAndMigrationReplacer") |
113 | 113 | ->callArtisan($migrationRequired) |
114 | 114 | ->build($this->column, ["migrationRequired" => $migrationRequired]); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | protected function buildRequests() |
150 | 150 | { |
151 | 151 | $builder = new KMRequestBuilder(); |
152 | - $requestClass = "$this->apiTitle" . "Request"; |
|
152 | + $requestClass = "$this->apiTitle"."Request"; |
|
153 | 153 | $builder->initialResource($requestClass, "requestReplacer") |
154 | 154 | ->callArtisan() |
155 | 155 | ->build($this->column); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | protected function buildController() |
171 | 171 | { |
172 | 172 | $builder = new KMControllerBuilder(); |
173 | - $controllerClass = "$this->apiTitle" . "Controller"; |
|
173 | + $controllerClass = "$this->apiTitle"."Controller"; |
|
174 | 174 | $controllerBuildType = !$this->baseControllerExists || $this->paths == null ? "basicBuild" : "build"; |
175 | 175 | return $builder->initialResource($controllerClass, "controllerReplacer") |
176 | 176 | ->callArtisan() |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | protected function buildResource() |
187 | 187 | { |
188 | 188 | $builder = new KMResourcesBuilder(); |
189 | - $resourceClass = "$this->apiTitle" . "Resource"; |
|
189 | + $resourceClass = "$this->apiTitle"."Resource"; |
|
190 | 190 | $builder->callArtisan($resourceClass); |
191 | - return $this->paths["{{ resource_path }}"] = KMFileFacade::getClassNameSpace("Resources", "$this->apiTitle" . "Resource"); |
|
191 | + return $this->paths["{{ resource_path }}"] = KMFileFacade::getClassNameSpace("Resources", "$this->apiTitle"."Resource"); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | { |
204 | 204 | $data = [ |
205 | 205 | "title" => $this->apiTitle, |
206 | - "controller" => "$this->apiTitle" . "Controller", |
|
206 | + "controller" => "$this->apiTitle"."Controller", |
|
207 | 207 | "url" => "$this->apiTitle", |
208 | 208 | "name" => "$this->apiTitle", |
209 | 209 | "type" => "resource", |
@@ -9,12 +9,12 @@ |
||
9 | 9 | { |
10 | 10 | public static function getRoutes() |
11 | 11 | { |
12 | - return Route::group([], function () { |
|
12 | + return Route::group([], function() { |
|
13 | 13 | $extraRoutes = KMFileFacade::getCredentialJsonFileAsJson(); |
14 | - if (isset($extraRoutes)){ |
|
14 | + if (isset($extraRoutes)) { |
|
15 | 15 | foreach ($extraRoutes as $api) { |
16 | 16 | if (isset($api->controller) && isset($api->url)) { |
17 | - $api->controller = str_replace('/' , '\\' , $api->controller); |
|
17 | + $api->controller = str_replace('/', '\\', $api->controller); |
|
18 | 18 | Route::apiResource($api->url, $api->controller); |
19 | 19 | } |
20 | 20 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public static function getFilesFromStubs($fileName) |
17 | 17 | { |
18 | - return __DIR__ . "/../Stubs/$fileName.stub"; |
|
18 | + return __DIR__."/../Stubs/$fileName.stub"; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public static function getFilesFromStubsAsStream($fileName) |
26 | 26 | { |
27 | - return File::get(__DIR__ . "/../Stubs/$fileName.stub"); |
|
27 | + return File::get(__DIR__."/../Stubs/$fileName.stub"); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @param string $path |
136 | 136 | * @return string |
137 | 137 | */ |
138 | - private static function correctPath($path){ |
|
139 | - return str_replace('\\' , ' /' , $path); |
|
138 | + private static function correctPath($path) { |
|
139 | + return str_replace('\\', ' /', $path); |
|
140 | 140 | } |
141 | 141 | } |