@@ -79,12 +79,46 @@ This library version introduces the following breaking changes:
79
79
of this behavior, you cannot have two separate ``id`` and ``_id`` fields in your
80
80
documents.
81
81
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 :
85
85
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);
88
122
89
123
.. _laravel-breaking-changes-v4.x:
90
124
0 commit comments