Skip to content

Commit 1f7dc84

Browse files
authored
Merge pull request #70 from bramr94/master
Add config option to not create crud folders.
2 parents 9f9e823 + 19d3161 commit 1f7dc84

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

config/api-postman.php

+3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@
3131
|
3232
| If you want folders to be generated based on namespace.
3333
|
34+
| Set "crud_folders" to "false" if you don't want the api, index, store, show etc. folders.
35+
|
3436
*/
3537

3638
'structured' => false,
39+
'crud_folders' => true,
3740

3841
/*
3942
|--------------------------------------------------------------------------

src/Commands/ExportPostmanCommand.php

+15
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,16 @@ public function handle(): void
168168
return ! is_null($value) && $value !== '';
169169
});
170170

171+
if (! $this->createCrudFolders()) {
172+
if (in_array(end($routeNames), ['index', 'store', 'show', 'update', 'destroy'])) {
173+
unset($routeNames[array_key_last($routeNames)]);
174+
}
175+
176+
if ($routeNames[0] == 'api') {
177+
unset($routeNames[0]);
178+
}
179+
}
180+
171181
$this->buildTree($this->structure, $routeNames, $request);
172182
} else {
173183
$this->structure['item'][] = $request;
@@ -387,6 +397,11 @@ protected function isStructured()
387397
return $this->config['structured'];
388398
}
389399

400+
protected function createCrudFolders()
401+
{
402+
return $this->config['crud_folders'];
403+
}
404+
390405
/**
391406
* Certain fields are not handled via the normal throw failure method in the validator
392407
* We need to add a human readable message.

0 commit comments

Comments
 (0)