We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents cb9ae42 + f46000c commit cfc0ce5Copy full SHA for cfc0ce5
src/HasFirestoreMirror.php
@@ -16,6 +16,10 @@ public static function bootHasFirestoreMirror(): void
16
static::saved(function ($model) {
17
$model->mirrorToFirestore();
18
});
19
+
20
+ static::deleting(function ($model) {
21
+ $model->deleteFromFirestore();
22
+ });
23
}
24
25
/**
@@ -32,6 +36,19 @@ public function mirrorToFirestore()
32
36
return $this;
33
37
34
38
39
+ /**
40
+ * Delete model from firestore.
41
+ *
42
+ * @return self
43
+ */
44
+ public function deleteFromFirestore()
45
+ {
46
+ Firestore::collection($this->getFirestoreCollectionName())
47
+ ->document($this->getFirestoreDocumentId())
48
+ ->delete();
49
50
+ return $this;
51
+ }
35
52
53
54
* Convert model to firestore document.
0 commit comments