]> _ Git - cubist_cms-back.git/commitdiff
wip #4258 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 15 Feb 2021 19:05:18 +0000 (20:05 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 15 Feb 2021 19:05:18 +0000 (20:05 +0100)
src/app/Magic/Models/CubistMagicAbstractModel.php
src/app/Magic/Models/Translate.php
src/app/Magic/Operations/CreateOperation.php [new file with mode: 0644]
src/app/Magic/Operations/UpdateOperation.php [new file with mode: 0644]

index 45de7bad0b5f3066c534aeeef25ab6f0132489cb..93b30b6d98f4d2517e1b3f70eb5e54cee1cf4c7c 100644 (file)
@@ -5,9 +5,9 @@ namespace Cubist\Backpack\Magic\Models;
 use Backpack\CRUD\app\Http\Controllers\Operations\BulkCloneOperation;
 use Backpack\CRUD\app\Http\Controllers\Operations\BulkDeleteOperation;
 use Backpack\CRUD\app\Http\Controllers\Operations\CloneOperation;
-use Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
+use Cubist\Backpack\Magic\Operations\CreateOperation;
 use Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
-use Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
+use Cubist\Backpack\Magic\Operations\UpdateOperation;
 use Cubist\Backpack\Http\Controllers\Operations\BulkPublishOperation;
 use Cubist\Backpack\Http\Controllers\Operations\ReviseOperation;
 use Backpack\CRUD\app\Library\CrudPanel\CrudPanel;
index 12298e41d92d51d3ac88fa9ca03c17dc9eeb0fa3..8a2ac0bc97ef9daf150b3fe860771f2d6d075197 100644 (file)
@@ -60,12 +60,20 @@ class Translate extends CubistMagicTranslatableModel
         parent::onBeforeUpdate($controller, $request); // TODO: Change the autogenerated stub
     }
 
+    public function onBeforeStore($controller, $request)
+    {
+        $this->saveLanguageFile($controller, $request);
+        parent::onBeforeStore($controller, $request); // TODO: Change the autogenerated stub
+    }
+
     /**
      * @param \Cubist\Backpack\Magic\Controllers\CubistMagicController $controller
      * @param \Cubist\Backpack\Magic\Requests\CubistMagicUpdateRequest $request
      */
     public function saveLanguageFile($controller, $request)
     {
+        dd(':)');
+
         $exclude = ['_token', '_method', 'http_referrer', 'locale', 'slug', 'id', 'k', 'save_action'];
 
         $translations = [];
diff --git a/src/app/Magic/Operations/CreateOperation.php b/src/app/Magic/Operations/CreateOperation.php
new file mode 100644 (file)
index 0000000..c8cee37
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+namespace Cubist\Backpack\Magic\Operations;
+use Cubist\Backpack\Magic\Models\CubistMagicAbstractModel;
+
+trait CreateOperation
+{
+    use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation {
+        store as _store;
+    }
+
+    public function store()
+    {
+        $res = $this->_store();
+        if($this->crud->entry instanceof CubistMagicAbstractModel) {
+            $this->crud->entry->onAfterSave();
+        }
+        return $res;
+    }
+}
diff --git a/src/app/Magic/Operations/UpdateOperation.php b/src/app/Magic/Operations/UpdateOperation.php
new file mode 100644 (file)
index 0000000..bdeadc8
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+
+namespace Cubist\Backpack\Magic\Operations;
+use Cubist\Backpack\Magic\Models\CubistMagicAbstractModel;
+
+trait UpdateOperation
+{
+    use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation{
+        update as _update;
+    }
+
+
+    /**
+     * Update the specified resource in the database.
+     *
+     * @return Response
+     */
+    public function update()
+    {
+        $res=$this->_update();
+        if($this->crud->entry instanceof CubistMagicAbstractModel) {
+            $this->crud->entry->onAfterSave();
+        }
+        return $res;
+    }
+}