From: Vincent Vanwaelscappel Date: Fri, 24 May 2019 13:37:48 +0000 (+0200) Subject: #2783 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ed231d0e6b98b707d58f03fd4918ded6f00b8ecd;p=cubist_cms-back.git #2783 --- diff --git a/src/app/Magic/CubistCrud.php b/src/app/Magic/CubistCrud.php index 08564ca..a175a32 100644 --- a/src/app/Magic/CubistCrud.php +++ b/src/app/Magic/CubistCrud.php @@ -4,22 +4,22 @@ namespace Cubist\Backpack\app\Magic; use Backpack\CRUD\CrudTrait; -use Cubist\Backpack\app\Magic\Fields\CubistMagicField; +use Cubist\Backpack\app\Magic\Fields\Field; trait CubistCrud { use CrudTrait; /** - * @param $field CubistMagicField|array + * @param $field Field|array * @throws \Exception */ public function addField($field) { if (is_array($field)) { - $field = CubistMagicField::getInstance($field); + $field = Field::getInstance($field); } - /** @var $field CubistMagicField */ + /** @var $field Field */ if ($field->isDisplayColumn()) { $this->crud->addColumn($field->getColumnData()); diff --git a/src/app/Magic/Fields/CubistMagicField.php b/src/app/Magic/Fields/CubistMagicField.php deleted file mode 100644 index c5d1fb8..0000000 --- a/src/app/Magic/Fields/CubistMagicField.php +++ /dev/null @@ -1,90 +0,0 @@ - 'text', 'column' => false, 'form' => 'both', 'rules' => '']; - } - - public function __construct($attributes) - { - $this->_attributes = array_merge($this->getDefaultAttributes(), $attributes); - $this->init(); - } - - public function getRules() - { - return $this->getAttribute('rules', ''); - } - - public function getDefinition() - { - return $this->_attributes; - } - - public function init() - { - - } - - /** - * @return bool - */ - public function isDisplayColumn() - { - return !!$this->getAttribute('column'); - } - - public function getColumnData() - { - $res = [ - 'type' => $this->getAttribute('column_type', $this->getAttribute('type')), - 'label' => $this->getAttribute('column_label', $this->getAttribute('label')) - ]; - - return $res; - } - - public function getCRUDForm() - { - return $this->getAttribute('form'); - } - - public function getDatabaseSchema() - { - - } -} diff --git a/src/app/Magic/Fields/Field.php b/src/app/Magic/Fields/Field.php new file mode 100644 index 0000000..481ada2 --- /dev/null +++ b/src/app/Magic/Fields/Field.php @@ -0,0 +1,90 @@ + 'text', 'column' => false, 'form' => 'both', 'rules' => '']; + } + + public function __construct($attributes) + { + $this->_attributes = array_merge($this->getDefaultAttributes(), $attributes); + $this->init(); + } + + public function getRules() + { + return $this->getAttribute('rules', ''); + } + + public function getDefinition() + { + return $this->_attributes; + } + + public function init() + { + + } + + /** + * @return bool + */ + public function isDisplayColumn() + { + return !!$this->getAttribute('column'); + } + + public function getColumnData() + { + $res = [ + 'type' => $this->getAttribute('column_type', $this->getAttribute('type')), + 'label' => $this->getAttribute('column_label', $this->getAttribute('label')) + ]; + + return $res; + } + + public function getCRUDForm() + { + return $this->getAttribute('form'); + } + + public function getDatabaseSchema() + { + + } +} diff --git a/src/app/Magic/Models/CubistMagicModelAbstract.php b/src/app/Magic/Models/CubistMagicModelAbstract.php index 291a4d5..e1341fc 100644 --- a/src/app/Magic/Models/CubistMagicModelAbstract.php +++ b/src/app/Magic/Models/CubistMagicModelAbstract.php @@ -4,7 +4,7 @@ namespace Cubist\Backpack\app\Magic\Models; use Backpack\CRUD\CrudTrait; -use Cubist\Backpack\app\Magic\Fields\CubistMagicField; +use Cubist\Backpack\app\Magic\Fields\Field; use Cubist\Backpack\app\Magic\Util; use Illuminate\Database\Eloquent\Model; use Cubist\Backpack\app\Magic\CubistMagicAttribute; @@ -17,7 +17,7 @@ class CubistMagicModelAbstract extends Model use CrudTrait; /** - * @var CubistMagicField[] + * @var Field[] */ protected $_fields = []; @@ -50,8 +50,8 @@ class CubistMagicModelAbstract extends Model */ public function addField($attributes) { - /** @var CubistMagicField $field */ - $field = CubistMagicField::getInstance($attributes); + /** @var Field $field */ + $field = Field::getInstance($attributes); $name = $field->getAttribute('name'); $this->_fields[$name] = $field; $this->fillable[] = $name; diff --git a/src/app/Magic/Requests/CubistMagicStoreRequest.php b/src/app/Magic/Requests/CubistMagicStoreRequest.php index adf513c..d1e8ccc 100644 --- a/src/app/Magic/Requests/CubistMagicStoreRequest.php +++ b/src/app/Magic/Requests/CubistMagicStoreRequest.php @@ -1,9 +1,7 @@