From: Vincent Vanwaelscappel Date: Mon, 15 Jun 2020 14:31:24 +0000 (+0200) Subject: wip #3699 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=23f9ed1de01382d64921c9a663502dbea246e6ea;p=cubist_cms-back.git wip #3699 @0.5 --- diff --git a/src/app/Magic/Fields/Field.php b/src/app/Magic/Fields/Field.php index 2e194e2..f11e28f 100644 --- a/src/app/Magic/Fields/Field.php +++ b/src/app/Magic/Fields/Field.php @@ -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; + } + } diff --git a/src/app/Magic/Fields/RolesPermissions.php b/src/app/Magic/Fields/RolesPermissions.php index 20b2535..3378237 100644 --- a/src/app/Magic/Fields/RolesPermissions.php +++ b/src/app/Magic/Fields/RolesPermissions.php @@ -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() { diff --git a/src/app/Magic/Models/CubistMagicAbstractModel.php b/src/app/Magic/Models/CubistMagicAbstractModel.php index a42e854..cee47bc 100644 --- a/src/app/Magic/Models/CubistMagicAbstractModel.php +++ b/src/app/Magic/Models/CubistMagicAbstractModel.php @@ -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); diff --git a/src/app/Magic/Models/CubistMagicAuthenticatable.php b/src/app/Magic/Models/CubistMagicAuthenticatable.php index 9b528a9..2d4c1e0 100644 --- a/src/app/Magic/Models/CubistMagicAuthenticatable.php +++ b/src/app/Magic/Models/CubistMagicAuthenticatable.php @@ -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']); diff --git a/src/resources/config/cubist.php b/src/resources/config/cubist.php index fe62b90..36533f2 100644 --- a/src/resources/config/cubist.php +++ b/src/resources/config/cubist.php @@ -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), ];