Skip to content

Commit

Permalink
- Added deleting event
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehmet Faruk Demirkoparan committed Oct 9, 2024
1 parent 46dd3e0 commit 605cf72
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Traits/Flexy.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,22 @@ public static function bootFlexy(): void
$flexyModelContract->flexy->setRawAttributes($flexyModelContract->flexy->getAttributes(), true);
FlexyField::dropAndCreatePivotView();
}

}

});

static::deleting(function (FlexyModelContract $flexyModelContract) {
$modelType = static::getModelType();
$modelId = $flexyModelContract->id;

Value::where([
'model_type' => $modelType,
'model_id' => $modelId,
])->delete();

FlexyField::dropAndCreatePivotView();
});
}

public static function setFlexyShape(
Expand Down

0 comments on commit 605cf72

Please sign in to comment.