-
Notifications
You must be signed in to change notification settings - Fork 1.4k
-
- 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
- _id
- accountId
alerts
- _id
- postId
- type
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.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
@w99910 are you able to solve it?
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment