afterReorder

Is it possible to add a function before or after saving the positions of my module? I need it in order to clear the cache of my site every time the position of the elements changes. I need something similar to this <?php namespace A17\Twill\Jobs; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Support\Facades\DB; use A17\Twill\Models\Model; class ReorderNestedModuleItems implements ShouldQueue { use Dispatchable; use InteractsWithQueue; use Queueable; protected $modelClass; protected $ids; public function __construct(Model $model, array $ids) { $this->modelClass = get_class($model); $this->ids = $ids; } public function handle() { DB::transaction(function () {
// Here custom function app($this->modelClass)->saveTreeFromIds($this->ids); }, 3); } }
5 Replies
ifox
ifox16mo ago
Hi @luciano.mizra a module with HasPosition but not nested, correct?
ifox
ifox16mo ago
GitHub
twill/src/Http/Controllers/Admin/ModuleController.php at 35d0bbcb8a...
Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. Chat with us on Discord at https://discord.gg/c...
ifox
ifox16mo ago
So you can listen to cms-module.saved
luciano.mizra
luciano.mizraOP16mo ago
Great, so I just need to place the "fireEvent" function in my controller.
ifox
ifox16mo ago
It's already fired when you reorder
Want results from more Discord servers?
Add your server