Skip to content

Commit 19bae2e

Browse files
committed
Merge branch '4.6' into paginator-total-override
2 parents d303169 + f6ee9cc commit 19bae2e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1341
-974
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -115,34 +115,17 @@ jobs:
115115
aws_region_name: ${{ vars.AWS_REGION_NAME }}
116116
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
117117

118-
- name: "Generate authorized publication document"
119-
uses: mongodb-labs/drivers-github-tools/authorized-pub@v2
118+
- name: "Generate SSDLC Reports"
119+
uses: mongodb-labs/drivers-github-tools/full-report@v2
120120
with:
121121
product_name: "MongoDB Laravel Integration"
122122
release_version: ${{ inputs.version }}
123-
filenames: ""
124-
token: ${{ env.GH_TOKEN }}
125-
126-
- name: "Download SBOM file from Silk"
127-
uses: mongodb-labs/drivers-github-tools/sbom@v2
128-
with:
129123
silk_asset_group: mongodb-laravel-integration
130124

131125
- name: "Upload SBOM as release artifact"
132126
run: gh release upload ${{ inputs.version }} ${{ env.S3_ASSETS }}/cyclonedx.sbom.json
133127
continue-on-error: true
134128

135-
- name: "Generate SARIF report from code scanning alerts"
136-
uses: mongodb-labs/drivers-github-tools/code-scanning-export@v2
137-
with:
138-
ref: ${{ inputs.version }}
139-
output-file: ${{ env.S3_ASSETS }}/code-scanning-alerts.json
140-
141-
- name: "Generate compliance report"
142-
uses: mongodb-labs/drivers-github-tools/compliance-report@v2
143-
with:
144-
token: ${{ env.GH_TOKEN }}
145-
146129
- name: Upload S3 assets
147130
uses: mongodb-labs/drivers-github-tools/upload-s3-assets@v2
148131
with:

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ All notable changes to this project will be documented in this file.
33

44
## [4.6.0] - upcoming
55

6+
* Add `DocumentTrait` to use any 3rd party model with MongoDB @GromNaN in [#2580](https://github.com/mongodb/laravel-mongodb/pull/2580)
67
* Add support for Closure for Embed pagination @GromNaN in [#3027](https://github.com/mongodb/laravel-mongodb/pull/3027)
78

89
## [4.5.0] - 2024-06-20
910

10-
* Add GridFS integration for Laravel File Storage by @GromNaN in [#2984](https://github.com/mongodb/laravel-mongodb/pull/2984)
11+
* Add GridFS integration for Laravel File Storage by @GromNaN in [#2985](https://github.com/mongodb/laravel-mongodb/pull/2985)
1112

1213
## [4.4.0] - 2024-05-31
1314

docs/fundamentals/read-operations.txt

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,13 @@ You can use Laravel's Eloquent object-relational mapper (ORM) to create models
5757
that represent MongoDB collections and chain methods on them to specify
5858
query criteria.
5959

60-
To retrieve documents that match a set of criteria, pass a query filter to the
61-
``where()`` method.
60+
To retrieve documents that match a set of criteria, call the ``where()``
61+
method on the collection's corresponding Eloquent model, then pass a query
62+
filter to the method.
6263

6364
A query filter specifies field value requirements and instructs the find
6465
operation to return only documents that meet these requirements.
6566

66-
You can use Laravel's Eloquent object-relational mapper (ORM) to create models
67-
that represent MongoDB collections. To retrieve documents from a collection,
68-
call the ``where()`` method on the collection's corresponding Eloquent model.
69-
7067
You can use one of the following ``where()`` method calls to build a query:
7168

7269
- ``where('<field name>', <value>)`` builds a query that matches documents in
@@ -79,7 +76,7 @@ You can use one of the following ``where()`` method calls to build a query:
7976
To apply multiple sets of criteria to the find operation, you can chain a series
8077
of ``where()`` methods together.
8178

82-
After building your query with the ``where()`` method, chain the ``get()``
79+
After building your query by using the ``where()`` method, chain the ``get()``
8380
method to retrieve the query results.
8481

8582
This example calls two ``where()`` methods on the ``Movie`` Eloquent model to
@@ -150,6 +147,60 @@ retrieve documents that meet the following criteria:
150147
To learn how to query by using the Laravel query builder instead of the
151148
Eloquent ORM, see the :ref:`laravel-query-builder` page.
152149

150+
Match Array Field Elements
151+
~~~~~~~~~~~~~~~~~~~~~~~~~~
152+
153+
You can specify a query filter to match array field elements when
154+
retrieving documents. If your documents contain an array field, you can
155+
match documents based on if the value contains all or some specified
156+
array elements.
157+
158+
You can use one of the following ``where()`` method calls to build a
159+
query on an array field:
160+
161+
- ``where('<array field>', <array>)`` builds a query that matches documents in
162+
which the array field value is exactly the specified array
163+
164+
- ``where('<array field>', 'in', <array>)`` builds a query
165+
that matches documents in which the array field value contains one or
166+
more of the specified array elements
167+
168+
After building your query by using the ``where()`` method, chain the ``get()``
169+
method to retrieve the query results.
170+
171+
Select from the following :guilabel:`Exact Array Match` and
172+
:guilabel:`Element Match` tabs to view the query syntax for each pattern:
173+
174+
.. tabs::
175+
176+
.. tab:: Exact Array Match
177+
:tabid: exact-array
178+
179+
This example retrieves documents in which the ``countries`` array is
180+
exactly ``['Indonesia', 'Canada']``:
181+
182+
.. literalinclude:: /includes/fundamentals/read-operations/ReadOperationsTest.php
183+
:language: php
184+
:dedent:
185+
:start-after: start-exact-array
186+
:end-before: end-exact-array
187+
188+
.. tab:: Element Match
189+
:tabid: element-match
190+
191+
This example retrieves documents in which the ``countries`` array
192+
contains one of the values in the array ``['Canada', 'Egypt']``:
193+
194+
.. literalinclude:: /includes/fundamentals/read-operations/ReadOperationsTest.php
195+
:language: php
196+
:dedent:
197+
:start-after: start-elem-match
198+
:end-before: end-elem-match
199+
200+
To learn how to query array fields by using the Laravel query builder instead of the
201+
Eloquent ORM, see the :ref:`laravel-query-builder-elemMatch` section in
202+
the Query Builder guide.
203+
153204
.. _laravel-retrieve-all:
154205

155206
Retrieve All Documents in a Collection
@@ -200,7 +251,7 @@ by the ``$search`` field in your query filter that you pass to the
200251
``where()`` method. The ``$text`` operator performs a text search on the
201252
text-indexed fields. The ``$search`` field specifies the text to search for.
202253

203-
After building your query with the ``where()`` method, chain the ``get()``
254+
After building your query by using the ``where()`` method, chain the ``get()``
204255
method to retrieve the query results.
205256

206257
This example calls the ``where()`` method on the ``Movie`` Eloquent model to

docs/includes/fundamentals/read-operations/ReadOperationsTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,35 @@ public function testTextRelevance(): void
133133
$this->assertCount(1, $movies);
134134
$this->assertEquals('this is a love story', $movies[0]->plot);
135135
}
136+
137+
/**
138+
* @runInSeparateProcess
139+
* @preserveGlobalState disabled
140+
*/
141+
public function exactArrayMatch(): void
142+
{
143+
// start-exact-array
144+
$movies = Movie::where('countries', ['Indonesia', 'Canada'])
145+
->get();
146+
// end-exact-array
147+
148+
$this->assertNotNull($movies);
149+
$this->assertCount(1, $movies);
150+
$this->assertEquals('Title 1', $movies[0]->title);
151+
}
152+
153+
/**
154+
* @runInSeparateProcess
155+
* @preserveGlobalState disabled
156+
*/
157+
public function arrayElemMatch(): void
158+
{
159+
// start-elem-match
160+
$movies = Movie::where('countries', 'in', ['Canada', 'Egypt'])
161+
->get();
162+
// end-elem-match
163+
164+
$this->assertNotNull($movies);
165+
$this->assertCount(2, $movies);
166+
}
136167
}

docs/index.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
/cache
2424
/queues
2525
/transactions
26+
/filesystems
2627
/issues-and-help
2728
/feature-compatibility
2829
/compatibility
@@ -73,6 +74,7 @@ see the following content:
7374
- :ref:`laravel-cache`
7475
- :ref:`laravel-queues`
7576
- :ref:`laravel-transactions`
77+
- :ref:`laravel-filesystems`
7678

7779
Issues & Help
7880
-------------

docs/queues.txt

Lines changed: 60 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,29 @@ Queues
99
:values: tutorial
1010

1111
.. meta::
12-
:keywords: php framework, odm, code example
12+
:keywords: php framework, odm, code example, jobs
1313

14-
If you want to use MongoDB as your database backend for Laravel Queue, change
15-
the driver in ``config/queue.php``:
14+
To use MongoDB as your database for Laravel Queue, change
15+
the driver in your application's ``config/queue.php`` file:
1616

1717
.. code-block:: php
1818

1919
'connections' => [
2020
'database' => [
2121
'driver' => 'mongodb',
22-
// You can also specify your jobs specific database created on config/database.php
22+
// You can also specify your jobs-specific database
23+
// in the config/database.php file
2324
'connection' => 'mongodb',
2425
'collection' => 'jobs',
2526
'queue' => 'default',
26-
'retry_after' => 60,
27+
// Optional setting
28+
// 'retry_after' => 60,
2729
],
2830
],
2931

32+
The following table describes properties that you can specify to configure
33+
the behavior of the queue:
34+
3035
.. list-table::
3136
:header-rows: 1
3237
:widths: 25 75
@@ -35,22 +40,29 @@ the driver in ``config/queue.php``:
3540
- Description
3641

3742
* - ``driver``
38-
- **Required**. Specifies the queue driver to use. Must be ``mongodb``.
43+
- **Required** Queue driver to use. The value of
44+
this property must be ``mongodb``.
3945

4046
* - ``connection``
41-
- The database connection used to store jobs. It must be a ``mongodb`` connection. The driver uses the default connection if a connection is not specified.
47+
- Database connection used to store jobs. It must be a
48+
``mongodb`` connection. The driver uses the default connection if
49+
a connection is not specified.
4250

4351
* - ``collection``
44-
- **Required**. Name of the MongoDB collection to store jobs to process.
52+
- **Required** Name of the MongoDB collection to
53+
store jobs to process.
4554

4655
* - ``queue``
47-
- **Required**. Name of the queue.
56+
- **Required** Name of the queue.
4857

4958
* - ``retry_after``
50-
- Specifies how many seconds the queue connection should wait before retrying a job that is being processed. Defaults to ``60``.
59+
- Specifies how many seconds the queue connection should wait
60+
before retrying a job that is being processed. The value is
61+
``60`` by default.
5162

52-
If you want to use MongoDB to handle failed jobs, change the database in
53-
``config/queue.php``:
63+
To use MongoDB to handle failed jobs, create a ``failed`` entry in your
64+
application's ``config/queue.php`` file and specify the database and
65+
collection:
5466

5567
.. code-block:: php
5668

@@ -60,6 +72,9 @@ If you want to use MongoDB to handle failed jobs, change the database in
6072
'collection' => 'failed_jobs',
6173
],
6274

75+
The following table describes properties that you can specify to configure
76+
how to handle failed jobs:
77+
6378
.. list-table::
6479
:header-rows: 1
6580
:widths: 25 75
@@ -68,32 +83,41 @@ If you want to use MongoDB to handle failed jobs, change the database in
6883
- Description
6984

7085
* - ``driver``
71-
- **Required**. Specifies the queue driver to use. Must be ``mongodb``.
86+
- **Required** Queue driver to use. The value of
87+
this property must be ``mongodb``.
7288

7389
* - ``connection``
74-
- The database connection used to store jobs. It must be a ``mongodb`` connection. The driver uses the default connection if a connection is not specified.
90+
- Database connection used to store jobs. It must be
91+
a ``mongodb`` connection. The driver uses the default connection
92+
if a connection is not specified.
7593

7694
* - ``collection``
77-
- Name of the MongoDB collection to store failed jobs. Defaults to ``failed_jobs``.
78-
95+
- Name of the MongoDB collection to store failed
96+
jobs. The value is ``failed_jobs`` by default.
7997

80-
Add the service provider in ``config/app.php``:
98+
Then, add the service provider in your application's
99+
``config/app.php`` file:
81100

82101
.. code-block:: php
83102

84103
MongoDB\Laravel\MongoDBQueueServiceProvider::class,
85104

86-
87105
Job Batching
88106
------------
89107

90-
`Job batching <https://laravel.com/docs/{+laravel-docs-version+}/queues#job-batching>`__
91-
is a Laravel feature to execute a batch of jobs and subsequent actions before,
92-
after, and during the execution of the jobs from the queue.
108+
**Job batching** is a Laravel feature that enables you to execute a
109+
batch of jobs and related actions before, after, and during the
110+
execution of the jobs from the queue. To learn more about this feature,
111+
see `Job Batching <https://laravel.com/docs/{+laravel-docs-version+}/queues#job-batching>`__
112+
in the Laravel documentation.
113+
114+
In MongoDB, you don't have to create a designated collection before
115+
using job batching. The ``job_batches`` collection is created
116+
automatically to store metadata about your job batches, such as
117+
their completion percentage.
93118

94-
With MongoDB, you don't have to create any collection before using job batching.
95-
The ``job_batches`` collection is created automatically to store meta
96-
information about your job batches, such as their completion percentage.
119+
To enable job batching, create the ``batching`` entry in your
120+
application's ``config/queue.php`` file:
97121

98122
.. code-block:: php
99123

@@ -103,6 +127,9 @@ information about your job batches, such as their completion percentage.
103127
'collection' => 'job_batches',
104128
],
105129

130+
The following table describes properties that you can specify to configure
131+
job batching:
132+
106133
.. list-table::
107134
:header-rows: 1
108135
:widths: 25 75
@@ -111,15 +138,20 @@ information about your job batches, such as their completion percentage.
111138
- Description
112139

113140
* - ``driver``
114-
- **Required**. Specifies the queue driver to use. Must be ``mongodb``.
141+
- **Required** Queue driver to use. The value of
142+
this property must be ``mongodb``.
115143

116144
* - ``connection``
117-
- The database connection used to store jobs. It must be a ``mongodb`` connection. The driver uses the default connection if a connection is not specified.
145+
- Database connection used to store jobs. It must be a
146+
``mongodb`` connection. The driver uses the default connection if
147+
a connection is not specified.
118148

119149
* - ``collection``
120-
- Name of the MongoDB collection to store job batches. Defaults to ``job_batches``.
150+
- Name of the MongoDB collection to store job
151+
batches. The value is ``job_batches`` by default.
121152

122-
Add the service provider in ``config/app.php``:
153+
Then, add the service provider in your application's ``config/app.php``
154+
file:
123155

124156
.. code-block:: php
125157

docs/transactions.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,16 @@ to another account:
9999
:start-after: begin transaction callback
100100
:end-before: end transaction callback
101101

102-
You can optionally pass the maximum number of times to retry a failed transaction as the second parameter as shown in the following code example:
102+
You can optionally pass the maximum number of times to retry a failed transaction
103+
as the second parameter, as shown in the following code example:
103104

104105
.. code-block:: php
105106
:emphasize-lines: 4
106107

107108
DB::transaction(function() {
108109
// transaction code
109110
},
110-
retries: 5,
111+
attempts: 5,
111112
);
112113

113114
.. _laravel-transaction-commit:

0 commit comments

Comments
 (0)