Skip to content

Issue in relationship #539

Answered by arthurkirkosa
wasiqaftab asked this question in Q&A
Feb 14, 2023 · 7 comments · 13 replies
Discussion options

You must be logged in to vote

Yes, as Contact has a BelongTo with User, that's the relation you have to use in your ContactRepository as well.

Because a Contact Belongs To a User, it's normal for you to have just one item of User loaded with that Contact

If you what the full list of contacts start from the User repo
GET /api/restify/users?related=userfriends

For clarity I would rename the methods in each model to the corresponding entity

// User

public function contacts(): HasMany {}
// or
public function friends(): HasMany {}

// Contact

public function user(): BelongsTo {}
// or
public function friend(): BelongsTo {}

Naming them in singular and plural would outline how many object I should receive when using the …

Replies: 7 comments 13 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by wasiqaftab
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@arthurkirkosa
Comment options

@wasiqaftab
Comment options

@wasiqaftab
Comment options

@arthurkirkosa
Comment options

@wasiqaftab
Comment options

Comment options

You must be logged in to vote
7 replies
@wasiqaftab
Comment options

@wasiqaftab
Comment options

@wasiqaftab
Comment options

@arthurkirkosa
Comment options

@wasiqaftab
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #538 on February 15, 2023 05:52.