Skip to content

Commit

Permalink
Merge pull request #13 from bhavingajjar/analysis-OMDQ4B
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
bhavingajjar authored Apr 15, 2021
2 parents 04c7239 + dbf5025 commit b8f7db7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
7 changes: 4 additions & 3 deletions src/LaravelApiGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -103,6 +103,7 @@ public function generateRoute()
}
$this->result = true;
}

return $this->result;
}

Expand Down

0 comments on commit b8f7db7

Please sign in to comment.