]> _ Git - cubist_cms-back.git/commitdiff
#2843
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 20 Jun 2019 14:45:39 +0000 (16:45 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 20 Jun 2019 14:45:39 +0000 (16:45 +0200)
src/app/Http/Controllers/CubistCrudController.php
src/app/Magic/BunchOfFields.php
src/app/Magic/Controllers/CubistMagicController.php
src/app/Magic/Models/CMSPage.php
src/app/Magic/Models/CubistMagicAbstractModel.php

index 725e4602f899bfa81e58cc3e2e957d777572811b..09b6b328db1461aa07f3da173f4213f4c7ea9a9c 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 
-namespace app\Http\Controllers;
+namespace Cubist\Backpack\app\Http\Controllers;
 
 
 use Backpack\CRUD\app\Http\Controllers\CrudController;
index 51afa4feb428663baa1bbfcfe6043161a0a0ef8c..cf21e4dd351b26c6d7ccae48cf0b7a6b54eab37a 100644 (file)
@@ -13,6 +13,12 @@ trait BunchOfFields
      */
     protected $_fields = [];
 
+
+    /**
+     * @var array
+     */
+    protected $defaultFieldAttributes = [];
+
     /**
      * @param $attributes
      * @return Field
@@ -20,6 +26,7 @@ trait BunchOfFields
      */
     public function addField(array $attributes)
     {
+        $attributes = array_merge($this->defaultFieldAttributes, $attributes);
         $field = Field::getInstance($attributes);
         $this->_fields[$field->getAttribute('name')] = $field;
 
index cdfc21df2674a82f84c7b6e6528797a07fb5b10b..457a24f0950c9e58715b142e04f093b171e34788 100644 (file)
@@ -3,7 +3,7 @@
 
 namespace Cubist\Backpack\app\Magic\Controllers;
 
-use Backpack\CRUD\app\Http\Controllers\CrudController;
+use Cubist\Backpack\app\Http\Controllers\CubistCrudController;
 use Backpack\CRUD\CrudTrait;
 use Gaspertrix\Backpack\DropzoneField\Traits\HandleAjaxMedia;
 
@@ -19,6 +19,7 @@ class CubistMagicController extends CubistCrudController
 
     public function __construct()
     {
+        parent::__construct();
     }
 
     public function _postSetModel()
index 7f60120de078f2da2220b0695acc60248a7dfc39..dedf6ae69919d661cc98c17a1c4b00e7159a09e9 100644 (file)
@@ -13,6 +13,8 @@ class CMSPage extends CubistMagicModel
         'singular' => 'page',
         'plural' => 'pages'];
 
+    protected $defaultFieldAttributes = ['translatable' => true];
+
     public function setFields()
     {
         parent::setFields();
@@ -22,7 +24,7 @@ class CMSPage extends CubistMagicModel
             'label' => 'Template',
             'options' => $this->getTemplates(),
             'column' => true,
-            'tab' => 'General',
+            'tab' => 'Informations principales',
         ]);
 
         $this->addField(['name' => 'name',
@@ -30,17 +32,13 @@ class CMSPage extends CubistMagicModel
             'type' => 'Text',
             'column' => true,
             'hint' => trans('for admin use'),
-            'tab' => 'General',
+            'tab' => 'Informations principales',
         ]);
 
         $this->addField(['name' => 'title',
             'label' => trans('Page title'),
             'type' => 'Text',
-        ]);
-
-        $this->addField(['name' => 'slug',
-            'type' => 'Slug',
-            'label' => 'Slug (URL)'
+            'tab' => 'Informations principales',
         ]);
 
         $this->_common();
@@ -54,7 +52,7 @@ class CMSPage extends CubistMagicModel
             'default' => '0',
             'label' => __('Status'),
             'options' => ['0' => __('Offline'), '1' => __('Published')],
-            'tab' => 'Général',
+            'tab' => 'Informations principales',
         ]);
         $this->_seo();
     }
@@ -66,24 +64,31 @@ class CMSPage extends CubistMagicModel
             'label' => trans('backpack::pagemanager.meta_title'),
             'type' => 'Text',
             'hint' => trans('If empty, page title is used.') . ' ' . __('Recommended length: 60 chars'),
-            'tab' => 'Meta // SEO',
-            'store_in'=>'seo',
+            'tab' => 'SEO // Meta',
+            'store_in' => 'seo',
         ]);
+
+        $this->addField(['name' => 'slug',
+            'type' => 'Slug',
+            'label' => 'Slug (URL)',
+            'tab' => 'SEO // Meta',
+        ]);
+
         $this->addFakeField([
             'name' => 'meta_description',
             'label' => trans('backpack::pagemanager.meta_description'),
             'type' => 'Textarea',
             'hint' => __('Recommended length: 160 chars'),
-            'tab' => 'Meta // SEO',
-            'store_in'=>'seo',
+            'tab' => 'SEO // Meta',
+            'store_in' => 'seo',
         ]);
         $this->addFakeField([
             'name' => 'robots',
             'label' => __('Allow page index by search engines'),
             'type' => 'Checkbox',
             'default' => true,
-            'tab' => 'Meta // SEO',
-            'store_in'=>'seo',
+            'tab' => 'SEO // Meta',
+            'store_in' => 'seo',
         ]);
     }
 
index 4f6ca8bbb2739279255db9d25d33803810011917..d27cbfae25d987dd917820e48a3741f498a2dfd8 100644 (file)
@@ -41,6 +41,7 @@ class CubistMagicAbstractModel extends Model implements HasMedia
     public $timestamps = true;
     public $clonable = true;
 
+
     /**
      * @var array
      */