]> _ Git - cubist_cms-back.git/commitdiff
wip #3699 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 15 Jun 2020 14:31:24 +0000 (16:31 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 15 Jun 2020 14:31:24 +0000 (16:31 +0200)
src/app/Magic/Fields/Field.php
src/app/Magic/Fields/RolesPermissions.php
src/app/Magic/Models/CubistMagicAbstractModel.php
src/app/Magic/Models/CubistMagicAuthenticatable.php
src/resources/config/cubist.php

index 2e194e261dc08f1ed4e310981e76e8161b9cee03..f11e28f5de5d58e42413336426f2931299c4e9b2 100644 (file)
@@ -13,9 +13,12 @@ use Cubist\Backpack\app\Magic\Models\CubistMagicAbstractModel;
 class Field implements \ArrayAccess
 {
     use CubistMagicAttribute;
+
     protected $_attributes;
     protected $_rules = [];
 
+    protected $_isRelationship = false;
+
     protected $_columnType = 'text';
     protected $_columnMoveAfter = false;
     protected $_columnFormat = null;
@@ -29,7 +32,7 @@ class Field implements \ArrayAccess
     protected $_databaseUnique = false;
     protected $_databaseIndex = false;
 
-    /** @var bool|string|array  */
+    /** @var bool|string|array */
     protected $_cast = false;
     protected $_translatable = false;
     protected $_migrateTranslatable = false;
@@ -253,4 +256,9 @@ class Field implements \ArrayAccess
         return $value;
     }
 
+    public function isRelationship()
+    {
+        return $this->_isRelationship;
+    }
+
 }
index 20b25353f3a00eb15c8caef6f8da2b92f75a281e..3378237b4acb76f56aa0304c3922e062d444cc66 100644 (file)
@@ -3,12 +3,12 @@
 
 namespace Cubist\Backpack\app\Magic\Fields;
 
-use Illuminate\Support\Str;
 
 class RolesPermissions extends Field
 {
     protected $_adminType = 'checklist_dependency';
     protected $_cast = ['roles' => 'json', 'permissions' => 'json'];
+    protected $_isRelationship = true;
 
     public function getDefinition()
     {
index a42e854d6ad0e93187343aefc13d8b6a5eef0bbd..cee47bc7ec98e99c36a91c3e1e2319cf1cfb0495 100644 (file)
@@ -241,7 +241,7 @@ class CubistMagicAbstractModel extends Model implements HasMedia
             if (!in_array($store_in, $this->fakeColumns)) {
                 $this->fakeColumns[] = $store_in;
             }
-        } else {
+        } else if (!$field->isRelationship()) {
             if ($field->getAttribute('fillable')) {
                 $this->fillable[] = $name;
             }
@@ -265,14 +265,6 @@ class CubistMagicAbstractModel extends Model implements HasMedia
         return $field;
     }
 
-    /**
-     * @param $field Field
-     */
-    protected function _addRelationship($field)
-    {
-        $this->_relationships[] = $field;
-    }
-
     public function generateCode()
     {
         $this->_generateControllerCode();
@@ -341,7 +333,7 @@ class CubistMagicAbstractModel extends Model implements HasMedia
 
         $table->setPrimaryKey([$this->primaryKey], 'pk_' . $this->table);
         foreach ($this->_fields as $field) {
-           if ($field->getAttribute('fake', false) !== false) {
+            if ($field->getAttribute('fake', false) !== false) {
                 continue;
             }
             $field->defineDbColumn($table);
index 9b528a94ac8e5a1cf95fb75eee25c17a2652bd94..2d4c1e0ebcb66a00eb828e185a3a01086f8f33ad 100644 (file)
@@ -58,7 +58,7 @@ class CubistMagicAuthenticatable extends CubistMagicAbstractModel
             'type' => 'checkbox',
             'tab' => 'Login']);
 
-        $this->addField(['name' => 'roles_and_permissions',
+        $this->addField(['name' => 'rolesandperms',
             'label' => '',
             'type' => 'RolesPermissions',
             'tab' => 'Roles & Permissions']);
index fe62b905db6bd9da1309088df87e0c779e8c6cac..36533f2b7e620ef90387ff26b885aff3ee22d8d1 100644 (file)
@@ -3,8 +3,8 @@
 return [
     'internal_search' => env('CUBIST_INTERNAL_SEARCH', false),
     'internal_search_index' => env('CUBIST_INTERNAL_SEARCH_INDEX', strtolower(env('APP_NAME', 'App_name') . '_' . env('APP_ENV', 'dev'))),
-    'page_model' => '\App\Models\Page',
-    'settings_model' => '\App\Models\Settings',
-    'locale_model' => '\App\Models\Locale',
+    'page_model' => App\Models\Page::class,
+    'settings_model' => App\Models\Settings::class,
+    'locale_model' => App\Models\Locale::class,
     'seo_robots' => env('SEO_ROBOTS', true),
 ];