From dbf5025c2fe962634a4eee2d54fd1b72e0146ec0 Mon Sep 17 00:00:00 2001 From: Bhavin Gajjar Date: Thu, 15 Apr 2021 09:43:54 +0000 Subject: [PATCH] Apply fixes from StyleCI --- config/config.php | 2 +- src/LaravelApiGenerator.php | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/config/config.php b/config/config.php index a29f869..adc60f4 100644 --- a/config/config.php +++ b/config/config.php @@ -14,7 +14,7 @@ | */ - 'model_directory_path' => is_dir(base_path('app/Models')) ? 'app/Models':'app', + 'model_directory_path' => is_dir(base_path('app/Models')) ? 'app/Models' : 'app', 'allow_cross_origin' => env('API_ALLOW_CROSS_ORIGIN', false), 'json_response' => env('API_JSON_RESPONSE', true), diff --git a/src/LaravelApiGenerator.php b/src/LaravelApiGenerator.php index fa5ea99..27ad433 100644 --- a/src/LaravelApiGenerator.php +++ b/src/LaravelApiGenerator.php @@ -83,18 +83,18 @@ public function generateCollection() public function generateRoute() { $this->result = false; - if(app()->version() >= 8 ){ + if (app()->version() >= 8) { $nameSpace = "\nuse App\Http\Controllers\Api\{{modelName}}Controller;"; $template = "Route::apiResource('{{modelNameLower}}', {{modelName}}Controller::class);\n"; $nameSpace = str_replace('{{modelName}}', $this->model, $nameSpace); - }else{ + } else { $template = "Route::apiResource('{{modelNameLower}}', 'Api\{{modelName}}Controller');\n"; } $route = str_replace('{{modelNameLower}}', Str::camel(Str::plural($this->model)), $template); $route = str_replace('{{modelName}}', $this->model, $route); if (! strpos(file_get_contents(base_path('routes/api.php')), $route)) { file_put_contents(base_path('routes/api.php'), $route, FILE_APPEND); - if(app()->version() >= 8 ){ + if (app()->version() >= 8) { if (! strpos(file_get_contents(base_path('routes/api.php')), $nameSpace)) { $lines = file(base_path('routes/api.php')); $lines[0] = $lines[0]."\n".$nameSpace; @@ -103,6 +103,7 @@ public function generateRoute() } $this->result = true; } + return $this->result; }