diff --git a/docs/upgrade.txt b/docs/upgrade.txt index 320734c49..9a0264bbc 100644 --- a/docs/upgrade.txt +++ b/docs/upgrade.txt @@ -79,12 +79,46 @@ This library version introduces the following breaking changes: of this behavior, you cannot have two separate ``id`` and ``_id`` fields in your documents. -- Removes support for the ``$collection`` property and associated methods. - The following list contains the removed methods and provides alternative methods - that you can use to replace the functionality: +- Removes support for the ``$collection`` property. The following code shows + how to specify a MongoDB collection name in your User class in older versions + compared to v5.0: - - ``DB::collection()``: use ``DB::table()`` - - ``Schema::collection()``: use ``Schema::table()`` + .. code-block:: php + :emphasize-lines: 11-12 + + use MongoDB\Laravel\Eloquent\Model; + + class User extends Model + { + protected $keyType = 'string'; + + // older versions + protected $collection = 'app_user'; + + // v5.0 + protected $table = 'app_user'; + + ... + } + + This release also updates the associated ``DB`` and ``Schema`` methods for + accessing a MongoDB collection. The following code shows how to access the + ``app_user`` collection in older versions compared to v5.0: + + .. code-block:: php + :emphasize-lines: 10-12 + + use Illuminate\Support\Facades\Schema; + use Illuminate\Support\Facades\DB; + use MongoDB\Laravel\Schema\Blueprint; + + // older versions + Schema::collection('app_user', function (Blueprint $collection) { ... }); + DB::collection('app_user')->find($id); + + // v5.0 + Schema::table('app_user', function (Blueprint $table) { ... }); + DB::table('app_user')->find($id); .. _laravel-breaking-changes-v4.x: