Skip to content

Commit cae6a1d

Browse files
committed
Add access config options
1 parent 4dc9cd7 commit cae6a1d

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

config/webfactor/documents.php

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,23 @@
44

55
// define the possible document types
66
// each type can exist exactly one time in the database
7-
'types' => [
7+
'types' => [
88
'imprint',
99
'privacy',
1010
'sbt'
1111
],
1212

13+
// define the access to the documents (see backpack for mor information)
14+
'access' => [
15+
// can users list documents
16+
'list' => true,
17+
'create' => false, // be sure to seed your documents if disabled
18+
'update' => true,
19+
'delete' => false,
20+
21+
/* 'revisions', reorder', 'show', 'details_row' */
22+
],
23+
1324
// define the used body type.
1425
// possible values are:
1526
// * plaintext
@@ -18,45 +29,45 @@
1829
// -> will present the summernote rich text editor and store styled html to the database
1930
// * md
2031
// -> will present the simplemde markdown editor and store markdown to the database
21-
'body_type' => 'md',
32+
'body_type' => 'md',
2233

2334
// the model to use with this package
2435
// keep in mind: when changing the model, you most likely need to change the Transformer also
25-
'model_class' => \Webfactor\Laravel\Backpack\Documents\Models\Document::class,
36+
'model_class' => \Webfactor\Laravel\Backpack\Documents\Models\Document::class,
2637

2738
// the transformer class used to transform the model for api responses
2839
'transformer_class' => \Webfactor\Laravel\Backpack\Documents\Transformers\DocumentTransformer::class,
2940

3041
// customize your backend parameters
31-
'backend' => [
42+
'backend' => [
3243

3344
// the CRUD controller to be used
34-
'controller' => Webfactor\Laravel\Backpack\Documents\Controllers\DocumentCrudController::class,
45+
'controller' => Webfactor\Laravel\Backpack\Documents\Controllers\DocumentCrudController::class,
3546

3647
// the route prefix for the default routes
3748
'route_prefix' => 'wfcms',
3849

3950
// the route endpoint for the default routes
40-
'route' => 'document',
51+
'route' => 'document',
4152

4253
// the midlewares to use
43-
'middleware' => ['web', 'admin']
54+
'middleware' => ['web', 'admin']
4455
],
4556

4657
// customize the api
47-
'api' => [
58+
'api' => [
4859

4960
// the API controller to be used
50-
'controller' => Webfactor\Laravel\Backpack\Documents\Controllers\DocumentApiController::class,
61+
'controller' => Webfactor\Laravel\Backpack\Documents\Controllers\DocumentApiController::class,
5162

5263
// the route prefix for the default routes
5364
'route_prefix' => 'api/v1',
5465

5566
// the route endpoint for the default routes
56-
'route' => 'documents',
67+
'route' => 'documents',
5768

5869
// the midlewares to use
59-
'middleware' => ['apiv1']
70+
'middleware' => ['apiv1']
6071
]
6172

6273
];

src/Controllers/DocumentCrudController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ public function setup()
6969

7070
// ------ CRUD ACCESS
7171

72+
collect(config('webfactor.documents.access', []))->each(function ($enabled, $key) {
73+
if ($enabled) {
74+
$this->crud->allowAccess($key);
75+
} else {
76+
$this->crud->denyAccess($key);
77+
}
78+
});
79+
7280
// ------ CRUD REORDER
7381

7482
// ------ CRUD DETAILS ROW

0 commit comments

Comments
 (0)