Skip to content

Commit cb953fb

Browse files
authored
Merge branch '4.2' into merge-4.1-into-4.2-1716209338791
2 parents d103849 + fb8359a commit cb953fb

18 files changed

+407
-35
lines changed

.github/workflows/build-ci.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,22 @@ jobs:
2424
- "8.2"
2525
- "8.3"
2626
laravel:
27-
- "10.*"
27+
- "10.*"
28+
- "11.*"
2829
include:
2930
- php: "8.1"
3031
laravel: "10.*"
3132
mongodb: "5.0"
3233
mode: "low-deps"
34+
os: "ubuntu-latest"
35+
- php: "8.4"
36+
laravel: "11.*"
37+
mongodb: "7.0"
38+
mode: "ignore-php-req"
39+
os: "ubuntu-latest"
40+
exclude:
41+
- php: "8.1"
42+
laravel: "11.*"
3343

3444
steps:
3545
- uses: "actions/checkout@v4"
@@ -76,8 +86,10 @@ jobs:
7686
restore-keys: "${{ matrix.os }}-composer-"
7787

7888
- name: "Install dependencies"
79-
run: composer update --no-interaction $([[ "${{ matrix.mode }}" == low-deps ]] && echo ' --prefer-lowest --prefer-stable')
80-
89+
run: |
90+
composer update --no-interaction \
91+
$([[ "${{ matrix.mode }}" == low-deps ]] && echo ' --prefer-lowest') \
92+
$([[ "${{ matrix.mode }}" == ignore-php-req ]] && echo ' --ignore-platform-req=php+')
8193
- name: "Run tests"
8294
run: "./vendor/bin/phpunit --coverage-clover coverage.xml"
8395
env:

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [4.2.2] - 2024-04-25
5+
6+
* Add return types to `FindAndModifyCommandSubscriber`, used by `firstOrCreate` by @wivaku in [#2913](https://github.com/mongodb/laravel-mongodb/pull/2913)
7+
8+
## [4.2.1] - 2024-04-25
9+
10+
* Set timestamps when using `Model::createOrFirst()` by @GromNaN in [#2905](https://github.com/mongodb/laravel-mongodb/pull/2905)
11+
12+
## [4.2.0] - 2024-03-14
13+
14+
* Add support for Laravel 11 by @GromNaN in [#2735](https://github.com/mongodb/laravel-mongodb/pull/2735)
15+
* Implement `Model::createOrFirst()` using findOneAndUpdate operation by @GromNaN in [#2742](https://github.com/mongodb/laravel-mongodb/pull/2742)
16+
417
## [4.1.3] - 2024-03-05
518

619
* Fix the timezone of `datetime` fields when they are read from the database. By @GromNaN in [#2739](https://github.com/mongodb/laravel-mongodb/pull/2739)

composer.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,21 @@
2424
"require": {
2525
"php": "^8.1",
2626
"ext-mongodb": "^1.15",
27-
"illuminate/support": "^10.0",
28-
"illuminate/container": "^10.0",
29-
"illuminate/database": "^10.30",
30-
"illuminate/events": "^10.0",
27+
"illuminate/support": "^10.0|^11",
28+
"illuminate/container": "^10.0|^11",
29+
"illuminate/database": "^10.30|^11",
30+
"illuminate/events": "^10.0|^11",
3131
"mongodb/mongodb": "^1.15"
3232
},
3333
"require-dev": {
3434
"phpunit/phpunit": "^10.3",
35-
"orchestra/testbench": "^8.0",
35+
"orchestra/testbench": "^8.0|^9.0",
3636
"mockery/mockery": "^1.4.4",
3737
"doctrine/coding-standard": "12.0.x-dev",
3838
"spatie/laravel-query-builder": "^5.6",
3939
"phpstan/phpstan": "^1.10"
4040
},
41+
"minimum-stability": "dev",
4142
"replace": {
4243
"jenssegers/mongodb": "self.version"
4344
},
@@ -66,9 +67,6 @@
6667
"cs:fix": "phpcbf"
6768
},
6869
"config": {
69-
"platform": {
70-
"php": "8.1"
71-
},
7270
"allow-plugins": {
7371
"dealerdirect/phpcodesniffer-composer-installer": true
7472
}

docs/eloquent-models/model-class.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,24 @@ type, to the Laravel ``datetime`` type.
194194
:emphasize-lines: 9-11
195195
:dedent:
196196

197+
.. tip:: Casts in Laravel 11
198+
199+
In Laravel 11, you can define a ``casts()`` method to specify data type conversions
200+
instead of using the ``$casts`` attribute. The following code performs the same
201+
conversion as the preceding example by using a ``casts()`` method:
202+
203+
.. code-block:: php
204+
205+
protected function casts(): array
206+
{
207+
return [
208+
'discovery_dt' => 'datetime',
209+
];
210+
}
211+
212+
To learn more, see `Attribute Casting <https://laravel.com/docs/{+laravel-docs-version+}/eloquent-mutators#attribute-casting>`__
213+
in the Laravel documentation.
214+
197215
This conversion lets you use the PHP `DateTime <https://www.php.net/manual/en/class.datetime.php>`__
198216
or the `Carbon class <https://carbon.nesbot.com/docs/>`__ to work with dates
199217
in this field. The following example shows a Laravel query that uses the

docs/fundamentals/read-operations.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ documents.
383383
Runtime: 95
384384
IMDB Rating: 4
385385
IMDB Votes: 9296
386-
Plot: A sci-fi update of the famous 6th Century poem. In a beseiged land, Beowulf must
386+
Plot: A sci-fi update of the famous 6th Century poem. In a besieged land, Beowulf must
387387
battle against the hideous creature Grendel and his vengeance seeking mother.
388388

389389
.. _laravel-sort:

docs/includes/framework-compatibility-laravel.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@
33
:stub-columns: 1
44

55
* - {+odm-short+} Version
6+
- Laravel 11.x
67
- Laravel 10.x
78
- Laravel 9.x
89

10+
* - 4.2
11+
- ✓
12+
- ✓
13+
-
14+
915
* - 4.1
16+
-
1017
- ✓
1118
-
1219

1320
* - 4.0
21+
-
1422
- ✓
1523
-
16-

docs/quick-start.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ that connects to a MongoDB deployment.
5353
.. tip::
5454

5555
You can download the complete web application project by cloning the
56-
`laravel-quickstart <https://github.com/mongodb-university/laravel-quickstart>`__
56+
`laravel-quickstart <https://github.com/mongodb-university/laravel-quickstart/>`__
5757
GitHub repository.
5858

5959
.. button:: Next: Download and Install

docs/quick-start/configure-mongodb.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,18 @@ Configure Your MongoDB Connection
7373

7474
.. step:: Add the {+odm-short+} provider
7575

76-
Open the ``app.php`` file in the ``config`` directory and
77-
add the following entry into the ``providers`` array:
76+
Open the ``providers.php`` file in the ``bootstrap`` directory and add
77+
the following entry into the array:
7878

7979
.. code-block::
8080

8181
MongoDB\Laravel\MongoDBServiceProvider::class,
8282

83+
.. tip::
84+
85+
To learn how to register the provider in Laravel 10.x, see
86+
`Registering Providers <https://laravel.com/docs/10.x/providers#registering-providers>`__.
87+
8388
After completing these steps, your Laravel web application is ready to
8489
connect to MongoDB.
8590

docs/quick-start/view-data.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ View MongoDB Data
6767

6868
public function show()
6969
{
70-
return view('browse_movies', [
71-
'movies' => Movie::where('runtime', '<', 60)
72-
->where('imdb.rating', '>', 8.5)
73-
->orderBy('imdb.rating', 'desc')
74-
->take(10)
75-
->get()
76-
]);
70+
return view('browse_movies', [
71+
'movies' => Movie::where('runtime', '<', 60)
72+
->where('imdb.rating', '>', 8.5)
73+
->orderBy('imdb.rating', 'desc')
74+
->take(10)
75+
->get()
76+
]);
7777
}
7878

7979
.. step:: Add a web route

docs/quick-start/write-data.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ Write Data to MongoDB
3232

3333
.. step:: Add an API route that calls the controller function
3434

35+
Generate an API route file by running the following command:
36+
37+
.. code-block:: bash
38+
39+
php artisan install:api
40+
41+
.. tip::
42+
43+
Skip this step if you are using Laravel 10.x because the file that
44+
the command generates already exists.
45+
3546
Import the controller and add an API route that calls the ``store()``
3647
method in the ``routes/api.php`` file:
3748

@@ -42,7 +53,7 @@ Write Data to MongoDB
4253
// ...
4354

4455
Route::resource('movies', MovieController::class)->only([
45-
'store'
56+
'store'
4657
]);
4758

4859

@@ -57,8 +68,8 @@ Write Data to MongoDB
5768

5869
class Movie extends Model
5970
{
60-
protected $connection = 'mongodb';
61-
protected $fillable = ['title', 'year', 'runtime', 'imdb', 'plot'];
71+
protected $connection = 'mongodb';
72+
protected $fillable = ['title', 'year', 'runtime', 'imdb', 'plot'];
6273
}
6374

6475
.. step:: Post a request to the API

0 commit comments

Comments
 (0)