]> _ Git - cubist_cms-back.git/commitdiff
wip #3458 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 3 Mar 2020 18:54:53 +0000 (19:54 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 3 Mar 2020 18:54:53 +0000 (19:54 +0100)
src/app/Magic/Controllers/CubistMagicController.php
src/app/Magic/Models/CubistMagicAbstractModel.php
src/app/Magic/Models/CubistMagicNestedModel.php
src/resources/cubistmagic/Controller.stub

index 291ffe6116a1270cc1d5e4fb93509b4a3c52d918..e4fa39b8556fdfbfe05c986bdc0a14855a718da2 100644 (file)
@@ -31,19 +31,6 @@ class CubistMagicController extends CubistCrudController
     protected $_oneInstance;
     protected $_nested = false;
 
-    // Routes
-////Route::post($this->name . '/bulk-translations-replace', [
-////'as' => 'crud.' . $this->name . '.bulkTranslationsReplace',
-////'uses' => $this->controller . '@bulkTranslationsReplace',
-////]);
-///
-///
-///
-///
-///
-///
-
-
     public function _postSetModel()
     {
 
@@ -107,10 +94,10 @@ class CubistMagicController extends CubistCrudController
         | CrudPanel Configuration
         |--------------------------------------------------------------------------
         */
-
-
         $this->crud->addColumn(['name' => $model->getPrimaryKey(), 'type' => 'number', 'label' => "#", 'searchLogic' => 'text']);
 
+        $this->getModelInstance()->setupButtons($this->crud);
+
         $this->updateFieldsFromModel($model);
     }
 
index 61413ddd9bfe5ba677e720d29e2237ee1ff9a1cc..6626a3015845e4717562f8e9c317b98d780f4eda 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace Cubist\Backpack\app\Magic\Models;
 
+use Backpack\CRUD\app\Library\CrudPanel\CrudPanel;
 use Backpack\CRUD\app\Models\Traits\CrudTrait;
 use Cubist\Backpack\app\Magic\BunchOfFields;
 use Cubist\Backpack\app\Magic\Controllers\CubistMagicController;
@@ -37,6 +38,8 @@ class CubistMagicAbstractModel extends Model implements HasMedia
     public $timestamps = true;
     public $clonable = true;
 
+    protected $_baseController = CubistMagicController::class;
+
     /**
      * @var array
      */
@@ -75,13 +78,35 @@ class CubistMagicAbstractModel extends Model implements HasMedia
     }
 
     public function __construct(array $attributes = [])
+    {
+
+        $this->setup();
+        $this->fill($attributes);
+    }
+
+    public function setup()
     {
         $this->setFields();
         $this->postSetFields();
         $this->bootIfNotBooted();
         $this->initializeTraits();
         $this->syncOriginal();
-        $this->fill($attributes);
+    }
+
+    /**
+     * @param $crud CrudPanel
+     */
+    public function setupButtons($crud)
+    {
+
+    }
+
+    /**
+     * @param $crud CrudPanel
+     */
+    public function setupFilters($crud)
+    {
+
     }
 
     public function newFromBuilder($attributes = [], $connection = null)
@@ -272,7 +297,7 @@ class CubistMagicAbstractModel extends Model implements HasMedia
      */
     protected function _getBaseController()
     {
-        return 'CubistMagicController';
+        return $this->_baseController;
     }
 
     protected function _replaceInCode($stub, $dest)
index 0af4a5fc803d6513853b8ff9e35d441a05502acb..93787de1df4ec7be894430f71ec0ae2eba7ad16c 100644 (file)
@@ -2,9 +2,13 @@
 
 namespace Cubist\Backpack\app\Magic\Models;
 
+use Cubist\Backpack\app\Magic\Controllers\CubistMagicNestedController;
+
 class CubistMagicNestedModel extends CubistMagicPageModel
 {
 
+    protected $_baseController = CubistMagicNestedController::class;
+
     public function setSchema($schema)
     {
         $table = parent::setSchema($schema);
@@ -20,22 +24,13 @@ class CubistMagicNestedModel extends CubistMagicPageModel
         return $table;
     }
 
-    /**
-     * @return string
-     */
-    protected function _getBaseController()
-    {
-        return 'CubistMagicNestedController';
-    }
-
-
     public static function getTree()
     {
 
-        try{
+        try {
             $all = self::orderBy('lft')->get();
-        }catch (\Exception $e){
-            $all=[];
+        } catch (\Exception $e) {
+            $all = [];
         }
         $res = [];
         self::_appendToTree($res, null, $all);
index 0c75b9c9b74992700451b8defbf0ac4e33344176..8502f055427283b66fcec2fdee4cf4c95ab44a13 100644 (file)
@@ -2,8 +2,6 @@
 
 namespace App\Http\Controllers\Admin;
 
-use Cubist\Backpack\app\Magic\Controllers\_EXTENDS_;
-
 class _CONTROLLERCLASS_ extends _EXTENDS_
 {
     protected $_modelNamespace = '_MODELNAMESPACE_';