]> _ Git - cubist_cms-back.git/commitdiff
wip #3546 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 3 Apr 2020 11:58:58 +0000 (13:58 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 3 Apr 2020 11:58:58 +0000 (13:58 +0200)
src/app/Magic/Fields/RolesPermissions.php [new file with mode: 0644]

diff --git a/src/app/Magic/Fields/RolesPermissions.php b/src/app/Magic/Fields/RolesPermissions.php
new file mode 100644 (file)
index 0000000..5600d15
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+
+namespace Cubist\Backpack\app\Magic\Fields;
+
+class RolesPermissions extends Field
+{
+    protected $_adminType = 'checklist_dependency';
+
+    public function getDefinition()
+    {
+        $res = parent::getDefinition();
+        $res['field_unique_name'] = 'user_role_permission';
+        $res['name'] = ['roles', 'permissions'];
+        $res['subfields'] = [
+            'primary' => [
+                'label' => trans('backpack::permissionmanager.roles'),
+                'name' => 'roles', // the method that defines the relationship in your Model
+                'entity' => 'roles', // the method that defines the relationship in your Model
+                'entity_secondary' => 'permissions', // the method that defines the relationship in your Model
+                'attribute' => 'name', // foreign key attribute that is shown to user
+                'model' => config('permission.models.role'), // foreign key model
+                'pivot' => true, // on create&update, do you need to add/delete pivot table entries?]
+                'number_columns' => 3, //can be 1,2,3,4,6
+            ],
+            'secondary' => [
+                'label' => ucfirst(trans('backpack::permissionmanager.permission_singular')),
+                'name' => 'permissions', // the method that defines the relationship in your Model
+                'entity' => 'permissions', // the method that defines the relationship in your Model
+                'entity_primary' => 'roles', // the method that defines the relationship in your Model
+                'attribute' => 'name', // foreign key attribute that is shown to user
+                'model' => config('permission.models.permission'), // foreign key model
+                'pivot' => true, // on create&update, do you need to add/delete pivot table entries?]
+                'number_columns' => 3, //can be 1,2,3,4,6
+            ],
+        ];
+        return $res;
+    }
+}