Skip to content

Commit 151bb98

Browse files
committed
JT feedback
1 parent fef5137 commit 151bb98

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

docs/upgrade.txt

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,46 @@ This library version introduces the following breaking changes:
7979
of this behavior, you cannot have two separate ``id`` and ``_id`` fields in your
8080
documents.
8181

82-
- Removes support for the ``$collection`` property and associated methods.
83-
The following list contains the removed methods and provides alternative methods
84-
that you can use to replace the functionality:
82+
- Removes support for the ``$collection`` property. The following code shows
83+
how to specify a MongoDB collection name in your User class in older versions
84+
compared to v5.0:
8585

86-
- ``DB::collection()``: use ``DB::table()``
87-
- ``Schema::collection()``: use ``Schema::table()``
86+
.. code-block:: php
87+
:emphasize-lines: 11-12
88+
89+
use MongoDB\Laravel\Eloquent\Model;
90+
91+
class User extends Model
92+
{
93+
protected $keyType = 'string';
94+
95+
// older versions
96+
protected $collection = 'app_user';
97+
98+
// v5.0
99+
protected $table = 'app_user';
100+
101+
...
102+
}
103+
104+
This release also updates the associated ``DB`` and ``Schema`` methods for
105+
accessing a MongoDB collection. The following code shows how to access the
106+
``app_user`` collection in older versions compared to v5.0:
107+
108+
.. code-block:: php
109+
:emphasize-lines: 10-12
110+
111+
use Illuminate\Support\Facades\Schema;
112+
use Illuminate\Support\Facades\DB;
113+
use MongoDB\Laravel\Schema\Blueprint;
114+
115+
// older versions
116+
Schema::collection('app_user', function (Blueprint $collection) { ... });
117+
DB::collection('app_user')->find($id);
118+
119+
// v5.0
120+
Schema::table('app_user', function (Blueprint $table) { ... });
121+
DB::table('app_user')->find($id);
88122

89123
.. _laravel-breaking-changes-v4.x:
90124

0 commit comments

Comments
 (0)