- Laravel-mongodb Version: ^3.8
- PHP Version: 8.0
- Database Driver & Version: mongodb driver - 3.6
Description:
I'm trying to implement belongsTo relationship with custom local key and foreign key.
Collection structure
posts
alerts
Expected behaviour
Here we will match accountId in posts collection and postId in alerts collection.
App\Models\Post
public function alert(){
return $this->belongsTo(App\Models\Alert::class,'postId','accountId');
}
Actual behaviour
When I dd App\Models\Alert::first()->alert , it returns null.