Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCSP-42956: Remove $collection support #3138

Merged
merged 7 commits into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions docs/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,47 @@ 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. The following code shows
how to assign a MongoDB collection to a variable in your ``User`` class in
older versions compared to v5.0:

.. code-block:: php
:emphasize-lines: 10-11

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 modifies 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: 9-11

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:

Version 4.x Breaking Changes
Expand Down
Loading