Skip to content

Add Mongo builder mixin to DocumentModel #3417

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

Open
wants to merge 1 commit into
base: 5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Builder extends EloquentBuilder
];

/**
* @return ($function is null ? AggregationBuilder : self)
* @return ($function is null ? AggregationBuilder : $this)
*
* @inheritdoc
*/
Expand Down
1 change: 1 addition & 0 deletions src/Eloquent/DocumentModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
use function strlen;
use function var_export;

/** @mixin Builder */
Copy link
Member

Choose a reason for hiding this comment

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

I had to remove the @mixin annotation from the Model class (#2981) because the return types of the methods is not the same in the Builder and the Model. I must have made a mistake.

trait DocumentModel
{
use HybridRelations;
Expand Down
6 changes: 0 additions & 6 deletions tests/Models/Anniversary.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@

use Illuminate\Database\Eloquent\Model;
use MongoDB\Laravel\Eloquent\DocumentModel;
use MongoDB\Laravel\Eloquent\Model as Eloquent;
use MongoDB\Laravel\Query\Builder;

/**
* @property string $name
* @property string $anniversary
* @mixin Eloquent
* @method static Builder create(...$values)
* @method static Builder truncate()
* @method static Eloquent sole(...$parameters)
*/
class Anniversary extends Model
{
Expand Down
6 changes: 0 additions & 6 deletions tests/Models/HiddenAnimal.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@

use Illuminate\Database\Eloquent\Model;
use MongoDB\Laravel\Eloquent\DocumentModel;
use MongoDB\Laravel\Eloquent\Model as Eloquent;
use MongoDB\Laravel\Query\Builder;

/**
* @property string $name
* @property string $country
* @property bool $can_be_eaten
* @mixin Eloquent
* @method static Builder create(...$values)
* @method static Builder truncate()
* @method static Eloquent sole(...$parameters)
*/
final class HiddenAnimal extends Model
{
Expand Down
Loading