Skip to content

fix for returning incorrect builder in hybrid relations #1326

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

Merged
merged 2 commits into from
Jan 8, 2018

Conversation

pimlie
Copy link
Contributor

@pimlie pimlie commented Oct 11, 2017

@jenssegers @Tucker-Eric

Commit 266305c introduced a bug when using HybridRelations in combination with e.g. raw methods. The newEloquentBuilder method always returned a Illuminate\Database\Eloquent\Builder but for Jenssegers\Mongodb\Eloquent\Model models it should return a Jenssegers\Mongodb\Eloquent\Builder.

@pimlie
Copy link
Contributor Author

pimlie commented Nov 7, 2017

@jenssegers Sorry for the failed test, I have fixed the CI and now it passes. I would be obliged if you could merge this :)

use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

class User extends Eloquent implements AuthenticatableContract, CanResetPasswordContract
{
use Authenticatable, CanResetPassword;
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not be needed right? Since Eloquent had this trait as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean, but I added the HybridRelations trait for the User model as using that trait immediately gives an error without this fix. In the first commit I used 2 use statements which I replaced to be 1 statement, therefor this line shows as deleted.

I dont think the Eloquent model class (either mongodb's or laravel's) implements one of these traits already

Copy link
Contributor

Choose a reason for hiding this comment

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

Jenssegers\Mongodb\Eloquent\Model already has the HybridRelations trait, which the model extends from.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah ok. Thanks for merging.

@jenssegers jenssegers merged commit 60c5329 into mongodb:master Jan 8, 2018
mnphpexpert added a commit to mnphpexpert/laravel-mongodb that referenced this pull request Sep 2, 2024
fix for returning incorrect builder in hybrid relations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants