Skip to content

Commit 60c5329

Browse files
authored
Merge pull request #1326 from pimlie/master
fix for returning incorrect builder in hybrid relations
2 parents 5a87639 + 23e8423 commit 60c5329

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Jenssegers/Mongodb/Eloquent/HybridRelations.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ protected function guessBelongsToManyRelation()
300300
*/
301301
public function newEloquentBuilder($query)
302302
{
303-
return new EloquentBuilder($query);
303+
if (is_subclass_of($this, \Jenssegers\Mongodb\Eloquent\Model::class)) {
304+
return new Builder($query);
305+
} else {
306+
return new EloquentBuilder($query);
307+
}
304308
}
305309
}

tests/models/User.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<?php
22

33
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
4+
use Jenssegers\Mongodb\Eloquent\HybridRelations;
45
use Illuminate\Auth\Authenticatable;
56
use Illuminate\Auth\Passwords\CanResetPassword;
67
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
78
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
89

910
class User extends Eloquent implements AuthenticatableContract, CanResetPasswordContract
1011
{
11-
use Authenticatable, CanResetPassword;
12+
use Authenticatable, CanResetPassword, HybridRelations;
1213

1314
protected $connection = 'mongodb';
1415
protected $dates = ['birthday', 'entry.date'];

0 commit comments

Comments
 (0)