]> _ Git - cubist_cms-back.git/commitdiff
fix #3468 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 6 Mar 2020 17:08:25 +0000 (18:08 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 6 Mar 2020 17:08:25 +0000 (18:08 +0100)
src/app/Magic/Fields/Date.php
src/app/Magic/Fields/Datetime.php
src/app/Magic/Fields/Field.php

index 0ee43a3b5ba364b3cceb1043b962a9e34651b898..3105e6b09be56ab700e294b8e72988157e5e68d4 100644 (file)
@@ -8,4 +8,6 @@ class Date extends Datetime
     protected $_adminType = 'date_picker';
     protected $_databaseType = 'date';
     protected $_cast = 'date';
+    protected $_columnType = 'date';
+    protected $_columnFormat = 'Y-m-d, H:i';
 }
index c9743f7b2bf765a3b9e3c73da97dae77eb05934f..b20bdb6bfcdb6de61cf920cd6db1f91cec7ef9e6 100644 (file)
@@ -9,6 +9,8 @@ class Datetime extends Field
     protected $_cast = 'datetime';
     protected $pickerOptions = ['format' => 'DD/MM/YYYY HH:mm', 'language' => 'fr'];
     protected $_databaseType = 'datetime';
+    protected $_columnType = 'datetime';
+    protected $_columnFormat = 'Y-m-d, H:i';
 
     public function _mutator($value)
     {
index cdcc59f765b5f8266a40d1d940a398dded2d828e..716b2560ae2b4538c4690d4e525a5e86609eadd1 100644 (file)
@@ -15,9 +15,10 @@ class Field implements \ArrayAccess
     use CubistMagicAttribute;
     protected $_attributes;
     protected $_rules = [];
-    protected $_columnType = 'text';
 
+    protected $_columnType = 'text';
     protected $_columnMoveAfter = false;
+    protected $_columnFormat = null;
 
     protected $_adminType = 'text';
     protected $_viewNamespace = 'crud::fields';
@@ -105,7 +106,7 @@ class Field implements \ArrayAccess
         return ['type' => $this->_adminType, 'view_namespace' => $this->_viewNamespace, 'column' => false, 'form' => 'both', 'rules' => '',
             'fillable' => true, 'guarded' => false, 'hidden' => false,
             'translatable' => $this->_translatable, 'migrateTranslatable' => $this->_migrateTranslatable,
-            'column_type' => $this->_columnType, 'column_move_after' => $this->_columnMoveAfter,
+            'column_type' => $this->_columnType, 'column_move_after' => $this->_columnMoveAfter, 'column_format' => $this->_columnFormat,
             'default' => '', 'cast' => $this->_cast, 'column_view_namespace' => $this->_columnViewNamespace, 'searchLogic' => $this->_searchLogic,
             'allow_null' => true,
             'can' => $this->_can, 'auth' => $this->_auth,
@@ -162,6 +163,7 @@ class Field implements \ArrayAccess
             'type' => $this->getAttribute('column_type'),
             'label' => $this->getAttribute('column_label', $this->getAttribute('label')),
             'searchLogic' => $this->getAttribute('searchLogic'),
+            'format' => $this->getAttribute('column_format', null)
         ];
 
         return $res;
@@ -178,6 +180,9 @@ class Field implements \ArrayAccess
     public function defineDbColumn($table)
     {
         $name = $this->getAttribute('name');
+        if ($name === 'created_at' || $name === 'updated_at') {
+            return;
+        }
         $table->addColumn($name,
             CubistMagicAbstractModel::toDoctrineType($this->getDatabaseType()),
             array_merge(