@@ -17,48 +17,90 @@ Delete Multiple Documents
1717 :depth: 1
1818 :class: singlecol
1919
20- You can delete multiple documents in a collection by calling the ``delete()`` method on an
21- object collection or a query builder.
20+ You can delete multiple documents in a collection by calling the
21+ ``delete()`` method on an object collection or a query builder.
2222
23- To delete multiple documents, pass a query filter to the ``where()`` method. Then, delete the
24- matching documents by calling the ``delete()`` method.
25-
26- Example
27- -------
28-
29- This usage example performs the following actions:
30-
31- - Uses the ``Movie`` Eloquent model to represent the ``movies`` collection in the
32- ``sample_mflix`` database
33- - Deletes documents from the ``movies`` collection that match a query filter
34- - Prints the number of deleted documents
35-
36- The example calls the following methods on the ``Movie`` model:
37-
38- - ``where()``: matches documents in which the value of the ``year`` field is less than or
39- equal to ``1910``.
40- - ``delete()``: deletes the matched documents. This method returns the number
41- of documents that the method successfully deletes.
42-
43- .. io-code-block::
44- :copyable: true
45-
46- .. input:: ../includes/usage-examples/DeleteManyTest.php
47- :start-after: begin-delete-many
48- :end-before: end-delete-many
49- :language: php
50- :dedent:
51-
52- .. output::
53- :language: console
54- :visible: false
55-
56- Deleted documents: 7
57-
58- .. include:: /includes/usage-examples/fact-edit-laravel-app.rst
23+ To delete multiple documents, pass a query filter to the ``where()``
24+ method. Then, delete the matching documents by calling the ``delete()``
25+ method.
5926
6027.. tip::
6128
6229 To learn more about deleting documents with the {+odm-short+}, see the :ref:`laravel-fundamentals-delete-documents`
6330 section of the Write Operations guide.
6431
32+ Example
33+ -------
34+
35+ Select from the following :guilabel:`Eloquent` and :guilabel:`Query
36+ Builder` tabs to view usage examples for the same operation that use
37+ each corresponding query syntax:
38+
39+ .. tabs::
40+
41+ .. tab:: Eloquent
42+ :tabid: eloquent-model-count
43+
44+ This example performs the following actions:
45+
46+ - Uses the ``Movie`` Eloquent model to represent the ``movies``
47+ collection in the ``sample_mflix`` database
48+ - Deletes documents from the ``movies`` collection that match a
49+ query filter
50+ - Prints the number of deleted documents
51+
52+ The example calls the following methods on the ``Movie`` model:
53+
54+ - ``where()``: Matches documents in which the value of the
55+ ``year`` field is less than or equal to ``1910``
56+ - ``delete()``: Deletes the matched documents and returns the
57+ number of documents successfully deleted
58+
59+ .. io-code-block::
60+ :copyable: true
61+
62+ .. input:: ../includes/usage-examples/DeleteManyTest.php
63+ :start-after: begin-eloquent-delete-many
64+ :end-before: end-eloquent-delete-many
65+ :language: php
66+ :dedent:
67+
68+ .. output::
69+ :language: console
70+ :visible: false
71+
72+ Deleted documents: 7
73+
74+ .. tab:: Query Builder
75+ :tabid: query-builder-count
76+
77+ This example performs the following actions:
78+
79+ - Accesses the ``movies`` collection by calling the ``table()``
80+ method from the ``DB`` facade
81+ - Deletes documents from the ``movies`` collection that match a
82+ query filter
83+ - Prints the number of deleted documents
84+
85+ The example calls the following query builder methods:
86+
87+ - ``where()``: Matches documents in which the value of the
88+ ``year`` field is less than or equal to ``1910``
89+ - ``delete()``: Deletes the matched documents and returns the
90+ number of documents successfully deleted
91+
92+ .. io-code-block::
93+
94+ .. input:: ../includes/usage-examples/DeleteManyTest.php
95+ :start-after: begin-qb-delete-many
96+ :end-before: end-qb-delete-many
97+ :language: php
98+ :dedent:
99+
100+ .. output::
101+ :language: console
102+ :visible: false
103+
104+ Deleted documents: 7
105+
106+ .. include:: /includes/usage-examples/fact-edit-laravel-app.rst
0 commit comments