Open
Description
JsonModel implements a ->delete()
method that emits deleting
and deleted
Eloquent events, then sets the model to null in the upstream model.
The problem is this won't work of the JsonModel is in a CollectionOfJsonModels, because the collection expects every element to continue to validate as the original model.
$deal->vehicles->find($vin)->delete(); // throws JsonSchemaValidationException : Vehicle contains invalid data!
so instead we've taken to using the very un-Eloquenty approach
$deal->vehicles->forget($vin)->save(); // Works but doesn't emit deleting or deleted events
Proposed Fix:
- Update ->delete to work for models in a collection.
- This might mean giving models some way to detect "am part of a collection"
- Update collection to use ->delete (to get events) under the covers
Metadata
Metadata
Assignees
Labels
No labels