Skip to content

Relation Not work has exception getRelationQuery incompatible #2406

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

Closed
BehroozBvk opened this issue Jun 23, 2022 · 4 comments
Closed

Relation Not work has exception getRelationQuery incompatible #2406

BehroozBvk opened this issue Jun 23, 2022 · 4 comments

Comments

@BehroozBvk
Copy link
Contributor

BehroozBvk commented Jun 23, 2022

  • Laravel-mongodb Version: 3.8.0
  • PHP Version: 7.4.3
  • Database Driver & Version: MongoDB server version: 5.0.7
  • Lumen version: 8.3.4

Description:

Steps to reproduce

1.This is my code

$bonus=\App\Models\Bonus::with('user_bonuses')->first();
  1. Bonus model is:
class Bonus extends Model
{
    protected $connection = 'mongodb';
    public $timestamps = false;

    public function user_bonuses()
    {
        return $this->hasMany(UserBonus::class);
    }
}
  1. UserBonus model is:
class UserBonus extends Model
{
    protected $connection = 'mongodb';
    protected $fillable = [
        'bonus_id',
        'user_id',
        'wallet_id',
        'scope',
        'amount',
        'status',
        'used_at',
    ];

    public function bonuses()
    {
        return $this->belongsTo(Bonus::class, 'id', 'bonus_id');
    }
}

Expected behaviour

As you can see, the code is expected to receive a bonus with all its user bonuses, but I get an exception.

Actual behaviour

But I have this exception:
[ErrorException] Declaration of Jenssegers\Mongodb\Relations\HasMany::getRelationQuery(Illuminate\Database\Eloquent\Builder $query, Illuminate\Database\Eloquent\Builder $parent, $columns = Array) should be compatible with Illuminate\Database\Eloquent\Relations\Relation::getRelationQuery()

Please, help me.
Thank you.

@jenssegers

@BehroozBvk BehroozBvk changed the title Relation With Not work has exception getRelationQuery incompatible Relation Not work has exception getRelationQuery incompatible Jun 23, 2022
@SanaviaNicolas
Copy link

Hi @BehroozBvk, try with this library: Laravel mongo auto sync.

@BehroozBvk
Copy link
Contributor Author

thanks @SanaviaNicolas . But I think this problem also needs to be solved.

@divine
Copy link
Contributor

divine commented Jun 23, 2022

thanks @SanaviaNicolas . But I think this problem also needs to be solved.

Update to the latest version. This was fixed in #2263.

Hi @BehroozBvk, try with this library: Laravel mongo auto sync.

Stop spamming on unrelated issues.

@BehroozBvk
Copy link
Contributor Author

thanks @SanaviaNicolas . But I think this problem also needs to be solved.

Update to the latest version. This was fixed in #2263.

Hi @BehroozBvk, try with this library: Laravel mongo auto sync.

Stop spamming on unrelated issues.

Thank you very so much. upgrated to 3.8.4 and solved the problem.

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

No branches or pull requests

3 participants