'Laravel 9 pivot relation , relation is not working

i'm using mongodb as my database

i updated laravel from 8 to 9

Database

fetch_data
    _id  

codes
   _id
 
fetch_data_codes
    _id
    fetch_data_id 
    codes_id 

I have two model

FetchData

 public function codes()
    {
        return $this->belongsToMany(Code::class, 'fetch_data_codes',
            'codes_id',
            'fetch_data_id');
    }

Codes

  public function fetch_data()
    {
        return $this->belongsToMany(FetchData::class,
            'fetch_data_codes',
            'fetch_data_id',
            'codes_id');
    }



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source