]> _ Git - cubist_cms-back.git/commitdiff
#2783
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 24 May 2019 13:37:48 +0000 (15:37 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 24 May 2019 13:37:48 +0000 (15:37 +0200)
src/app/Magic/CubistCrud.php
src/app/Magic/Fields/CubistMagicField.php [deleted file]
src/app/Magic/Fields/Field.php [new file with mode: 0644]
src/app/Magic/Models/CubistMagicModelAbstract.php
src/app/Magic/Requests/CubistMagicStoreRequest.php

index 08564ca53ccd9719fd36474965751da6407c804b..a175a32288529bf3561dd5b86dcefcdfdc8b4a9e 100644 (file)
@@ -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 (file)
index c5d1fb8..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-
-
-namespace Cubist\Backpack\app\Magic\Fields;
-
-use Cubist\Backpack\app\Magic\CubistMagicAttribute;
-use Exception;
-
-class CubistMagicField
-{
-    use CubistMagicAttribute;
-    protected $_attributes;
-    protected $_rules = [];
-
-    /**
-     * @param $attributes
-     * @return CubistMagicField
-     * @throws Exception
-     */
-    public static function getInstance($attributes)
-    {
-        if (!isset($attributes['type'])) {
-            throw new Exception('You must specify a field type');
-        }
-        if (!isset($attributes['name'])) {
-            throw new Exception('You must specify a field name');
-        }
-        $class = static::_getClass($attributes['type']);
-        return new $class($attributes);
-    }
-
-    protected static function _getClass($type)
-    {
-        return self::class;
-    }
-
-    public function getDefaultAttributes()
-    {
-        return ['type' => '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 (file)
index 0000000..481ada2
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+
+
+namespace Cubist\Backpack\app\Magic\Fields;
+
+use Cubist\Backpack\app\Magic\CubistMagicAttribute;
+use Exception;
+
+class Field
+{
+    use CubistMagicAttribute;
+    protected $_attributes;
+    protected $_rules = [];
+
+    /**
+     * @param $attributes
+     * @return Field
+     * @throws Exception
+     */
+    public static function getInstance($attributes)
+    {
+        if (!isset($attributes['type'])) {
+            throw new Exception('You must specify a field type');
+        }
+        if (!isset($attributes['name'])) {
+            throw new Exception('You must specify a field name');
+        }
+        $class = static::_getClass($attributes['type']);
+        return new $class($attributes);
+    }
+
+    protected static function _getClass($type)
+    {
+        return self::class;
+    }
+
+    public function getDefaultAttributes()
+    {
+        return ['type' => '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()
+    {
+
+    }
+}
index 291a4d565171b77005d9151f7be9737eff2e5d2f..e1341fc260eb5270c0e3fff58495ce980dc16e3b 100644 (file)
@@ -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;
index adf513c6b6ad4374ee8009c1cbab32f3ec289ec6..d1e8ccc19f5f8d7ff668d1df8c78a8474035c49a 100644 (file)
@@ -1,9 +1,7 @@
 <?php
 
-
 namespace Cubist\Backpack\app\Magic\Requests;
 
-
 use app\Magic\Requests\CubistMagicRequest;
 
 class CubistMagicStoreRequest extends CubistMagicRequest