I'm getting below error in my laravel application getting belongsToMany
relationship data in the repository. The application only has MongoDB database only. no hybrid with MySQL or any other.
message "BelongsToMany Is Not supported for hybrid query constraints!"
exception "Exception"
file "/var/www/backend/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php"
line 115
Repository code is like below.
$moduleInfo = $this->page->whereHas('section', function ($q) use ($module_id) {
$q->whereHas('chapters', function ($r) use ($module_id) {
$r->whereHas('modules', function ($s) use ($module_id) {
$s->where('_id', $module_id);
});
});
})
->with([
'section' => function ($q) {
$q->with([
'chapters' => function ($r) {
$r->with('modules');
}
]);
}
])
->get()
->toArray();
in Page Model
public function section()
{
return $this->belongsToMany( 'App\Models\Section', 'page_id', 'page_ids' );
}
I'm using jenssegers/mongodb package to connect mongo DB and laraval version is 5.6 jenssegers/mongodb version is 3.4
Data seems fine. Does anyone know the reason for this issue?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire