Skip to content

withCount is not working  #3003

Open
Open
@Rahul-codoffer

Description

@Rahul-codoffer
  • Laravel-mongodb Version: 4.3
  • PHP Version:8.3.7

Description:

Getting This method is not supported by MongoDB. Try "toMql()" instead on withCount function

Activity

omerkoseoglu

omerkoseoglu commented on Jun 14, 2024

@omerkoseoglu
Rahul-codoffer

Rahul-codoffer commented on Jun 17, 2024

@Rahul-codoffer
Author
GromNaN

GromNaN commented on Jun 17, 2024

@GromNaN
Member

Could you please provide a sample code to reproduce the issue. Some features are not supported with MongoDB or require some additional work.

hooman-mirghasemi

hooman-mirghasemi commented on Jun 29, 2024

@hooman-mirghasemi

I have same problem in laravel 10 php 8.3 and this package latest version 4.5

GromNaN

GromNaN commented on Jun 29, 2024

@GromNaN
Member

@hooman-mirghasemi Same question.

Could you please provide a sample code to reproduce the issue. Some features are not supported with MongoDB or require some additional work.

hooman-mirghasemi

hooman-mirghasemi commented on Jul 4, 2024

@hooman-mirghasemi

make a model in mysql "post"
then make an other one in mongo db "comments"
make hybrid relationships

Post::withCount('comments')->get();

MiladAheshmeh

MiladAheshmeh commented on Aug 28, 2024

@MiladAheshmeh
MiladAheshmeh

MiladAheshmeh commented on Sep 10, 2024

@MiladAheshmeh
alcaeus

alcaeus commented on Sep 10, 2024

@alcaeus
arjundexbytes

arjundexbytes commented on Mar 11, 2025

@arjundexbytes

Same issue with me

Athul-Suresh

Athul-Suresh commented on Jul 3, 2025

@Athul-Suresh

Same issue with me also
"php": "^8.2",
"laravel/framework": "^12.0",
"mongodb/laravel-mongodb": "^5.4",

Sample Code

Post::where('status",1)->withCount('comments')->get()

Error:
"message": "This method is not supported by MongoDB. Try "toMql()" instead.",
"exception": "BadMethodCallException",

alcaeus

alcaeus commented on Jul 9, 2025

@alcaeus
Member

We are tracking this internally as PHPORM-238 and will close out this issue once we've added support for withCount.

Athul-Suresh

Athul-Suresh commented on Jul 10, 2025

@Athul-Suresh

We are tracking this internally as PHPORM-238 and will close out this issue once we've added support for withCount.

Thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      withCount is not working · Issue #3003 · mongodb/laravel-mongodb