-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
- 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();
- Bonus model is:
class Bonus extends Model
{
protected $connection = 'mongodb';
public $timestamps = false;
public function user_bonuses()
{
return $this->hasMany(UserBonus::class);
}
}
- 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.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
[-]Relation With Not work has exception getRelationQuery incompatible[/-][+]Relation Not work has exception getRelationQuery incompatible[/+]SanaviaNicolas commentedon Jun 23, 2022
Hi @BehroozBvk, try with this library: Laravel mongo auto sync.
BehroozBvk commentedon Jun 23, 2022
thanks @SanaviaNicolas . But I think this problem also needs to be solved.
divine commentedon Jun 23, 2022
Update to the latest version. This was fixed in #2263.
Stop spamming on unrelated issues.
BehroozBvk commentedon Jun 24, 2022
Thank you very so much. upgrated to 3.8.4 and solved the problem.