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

Conversation

norareidy
Copy link
Contributor

@norareidy norareidy commented Sep 5, 2024

JIRA - https://jira.mongodb.org/browse/DOCSP-42956
Staging - https://deploy-preview-136--docs-laravel.netlify.app/upgrade/#version-5.x-breaking-changes

Checklist

  • Add tests and ensure they pass
  • Add an entry to the CHANGELOG.md file

@github-actions github-actions bot added the docs label Sep 5, 2024
@norareidy norareidy changed the title DOCSP-42956: Remove support DOCSP-42956: Remove $collection support Sep 5, 2024
@norareidy norareidy marked this pull request as ready for review September 5, 2024 19:51
@norareidy norareidy requested a review from a team as a code owner September 5, 2024 19:51
Copy link
Contributor

@rustagir rustagir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with a wording change suggestion

docs/upgrade.txt Outdated Show resolved Hide resolved
docs/upgrade.txt Outdated
Comment on lines 86 to 89
- ``Model::collection()``: use ``Model::table()``
- ``DB::collection()``: use ``DB::table()``
- ``Connection::collection()``: use ``Connection::table()``
- ``Schema::collection()``: use ``Schema::table()``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually there is only 2 methods removed in MongoDB\Laravel\Connection and MongoDB\Laravel\Schema\Builder, where they can be used as instance method.

But they are exposed in the Laravel facades Illuminate\Support\Facades\DB and Illuminate\Support\Facades, which expose them as static method. (Yes, this is very confusing).

Suggested change
- ``Model::collection()``: use ``Model::table()``
- ``DB::collection()``: use ``DB::table()``
- ``Connection::collection()``: use ``Connection::table()``
- ``Schema::collection()``: use ``Schema::table()``
- ``DB::collection()``: use ``DB::table()``
- ``Schema::collection()``: use ``Schema::table()``

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I see, updated! Should I mention the static methods here?

Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better with a diff of the changes to be made.

use MongoDB\Laravel\Eloquent\Model;

class User extends Model
{
    protected $keyType = 'string';
-   protected $collection = 'app_user';
+   protected $table = 'app_user';

    ...
}
use Illuminate\Support\Facades\DB;

- DB::collection('app_user')->find($id);
+ DB::table('app_user')->find($id);
use Illuminate\Support\Facades\Schema;
use MongoDB\Laravel\Schema\Blueprint;

- Schema::collection('app_user', function (Blueprint $collection) { ... });
+ Schema::table('app_user', function (Blueprint $table) { ... });

@norareidy norareidy merged commit f65b9e0 into mongodb:5.0 Sep 10, 2024
15 checks passed
@norareidy norareidy deleted the DOCSP-42956-remove-collection branch September 10, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants