Skip to content

Model getters does not works with ->project() #2021

@Siebov

Description

@Siebov
  • Laravel-mongodb Version: 3.5.3
  • PHP Version: 7.4.2
  • Database Driver & Version: not related

Description:

Getter mutator attribute does not works with ->project() statement in query.

Steps to reproduce

1.Define getNameAttribute($value) { return 'Test name'; } getter function in User (or any other).
2.Create a query using

$someModel
->with(['user' => function ($q) { 
    $q->project([
        '_id' => 1, 
        'name' => 1
]) 
}])

Expected behaviour

The value of user.name in the results should the value of the name after getter, because it's model based Moloquent query and not a raw one.

Actual behaviour

The value of user.name is a raw value from DB, without any getter mutation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions