Skip to content

Relation Not work has exception getRelationQuery incompatible #2406

@BehroozBvk

Description

@BehroozBvk
Contributor
  • 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

Activity

changed the title [-]Relation With Not work has exception getRelationQuery incompatible[/-] [+]Relation Not work has exception getRelationQuery incompatible[/+] on Jun 23, 2022
SanaviaNicolas

SanaviaNicolas commented on Jun 23, 2022

@SanaviaNicolas

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

BehroozBvk

BehroozBvk commented on Jun 23, 2022

@BehroozBvk
ContributorAuthor

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

divine

divine commented on Jun 23, 2022

@divine
Contributor

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

BehroozBvk commented on Jun 24, 2022

@BehroozBvk
ContributorAuthor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @BehroozBvk@divine@SanaviaNicolas

        Issue actions

          Relation Not work has exception getRelationQuery incompatible · Issue #2406 · mongodb/laravel-mongodb