Skip to content

Commit

Permalink
Merge branch '4.8' into merge-4.7-into-4.8-1724687399102
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN authored Aug 27, 2024
2 parents efab63b + 500ae9b commit 62f6449
Show file tree
Hide file tree
Showing 43 changed files with 807 additions and 486 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# Changelog
All notable changes to this project will be documented in this file.

## [4.7.2] - coming soon
## [4.8.0] - 2024-08-27

* Add `Query\Builder::incrementEach()` and `decrementEach()` methods by @SmallRuralDog in [#2550](https://github.com/mongodb/laravel-mongodb/pull/2550)
* Add `Query\Builder::whereLike()` and `whereNotLike()` methods by @GromNaN in [#3108](https://github.com/mongodb/laravel-mongodb/pull/3108)
* Deprecate `Connection::collection()` and `Schema\Builder::collection()` methods by @GromNaN in [#3062](https://github.com/mongodb/laravel-mongodb/pull/3062)
* Deprecate `Model::$collection` property to customize collection name. Use `$table` instead by @GromNaN in [#3064](https://github.com/mongodb/laravel-mongodb/pull/3064)

## [4.7.2] - 2024-08-27

* Add `Query\Builder::upsert()` method with a single document by @GromNaN in [#3100](https://github.com/mongodb/laravel-mongodb/pull/3100)

Expand Down
4 changes: 2 additions & 2 deletions docs/eloquent-models/model-class.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Change the Model Collection Name

By default, the model uses the snake case plural form of your model
class name. To change the name of the collection the model uses to retrieve
and save data in MongoDB, override the ``$collection`` property of the model
and save data in MongoDB, override the ``$table`` property of the model
class.

.. note::
Expand All @@ -127,7 +127,7 @@ The following example specifies the custom MongoDB collection name,
:emphasize-lines: 9
:dedent:

Without overriding the ``$collection`` property, this model maps to the
Without overriding the ``$table`` property, this model maps to the
``planets`` collection. With the overridden property, the example class stores
the model in the ``celestial_body`` collection.

Expand Down
16 changes: 11 additions & 5 deletions docs/fundamentals/database-collection.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ create a database connection to the ``animals`` database in the

.. code-block:: php
:emphasize-lines: 1,8

'default' => 'mongodb',

'connections' => [
Expand All @@ -77,7 +77,7 @@ The following example shows how to specify multiple database connections
``plants`` databases:

.. code-block:: php

'connections' => [

'mongodb' => [
Expand Down Expand Up @@ -145,16 +145,22 @@ Laravel retrieves results from the ``flowers`` collection:

Flower::where('name', 'Water Lily')->get()

.. note::

Starting in {+odm-short+} v4.8, the ``DB::collection()`` method
is deprecated. As shown in the following example, you can use the ``DB::table()``
method to access a MongoDB collection.

If you are unable to accomplish your operation by using an Eloquent
model, you can access the query builder by calling the ``collection()``
model, you can access the query builder by calling the ``table()``
method on the ``DB`` facade. The following example shows the same query
as in the preceding example, but the query is constructed by using the
``DB::collection()`` method:
``DB::table()`` method:

.. code-block:: php

DB::connection('mongodb')
->collection('flowers')
->table('flowers')
->where('name', 'Water Lily')
->get()

Expand Down
2 changes: 1 addition & 1 deletion docs/includes/auth/AuthUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class User extends Authenticatable
{
protected $connection = 'mongodb';
protected $collection = 'users';
protected $table = 'users';

protected $fillable = [
'name',
Expand Down
2 changes: 1 addition & 1 deletion docs/includes/auth/PersonalAccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PersonalAccessToken extends SanctumToken
use DocumentModel;

protected $connection = 'mongodb';
protected $collection = 'personal_access_tokens';
protected $table = 'personal_access_tokens';
protected $primaryKey = '_id';
protected $keyType = 'string';
}
2 changes: 1 addition & 1 deletion docs/includes/eloquent-models/PlanetCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

class Planet extends Model
{
protected $collection = 'celestial_body';
protected $table = 'celestial_body';
}
2 changes: 1 addition & 1 deletion docs/includes/fundamentals/read-operations/Movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
class Movie extends Model
{
protected $connection = 'mongodb';
protected $collection = 'movies';
protected $table = 'movies';
protected $fillable = ['title', 'year', 'runtime', 'imdb', 'plot'];
}
Loading

0 comments on commit 62f6449

Please sign in to comment.