October CMS Plugin Models Relations
I am using a messages plugin by Autumn. https://github.com/gpasztor87/oc-messages-plugin It has 3 models in it (message, thread and participant) and now I want to create a separate section for this plugin in backend. I created a plugin using builder, I made a new model called "message", now the thing is that when I delete a message entry, I need it to delete other table entries associated to this message. Database is related like: thread has many messages and many participants.
The question is: should I create all 3 separate models in my new backend plugin or I should use the already created ones from the original plugin? Also, is it better to make a relation using October CMS or I could create some function onDelete() and just delete all related entries? If so, how could I make this function? Is there some thing like onDelete hook or something?
I managed to solve this by creating all three models in my new plugin and just adding relations on each one of them like this:
public $hasMany = [ 'messages' => [ 'Autumn\Messages\Models\Message', 'delete' => true ], 'participants' => [ 'Autumn\Messages\Models\Participant', 'delete' => true ] ];
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?