Skip to content

Relation Not work has exception getRelationQuery incompatible #2406

Closed
@BehroozBvk

Description

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

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

    Issue actions