how to prevent the club liked by one user from being updated by another user

how to prevent the club liked by one user from being updated by another user

  

hi friends,

                 how to prevent the club liked by one user from being updated by another user when he like same club.I have attached my module for your referenceInline image 1


screenshot with second user logged in 

Inline image 2

Hi Karthik,

Do you want to relate the "like" to the user, am I right, i.e. if a user likes a club other user is not forced to also like it? 

If yes, you must associate the user id to the club in the database. A possible solution is to create an entity where each record has an attribute with the User Id and the Id of the Club he liked.

Does it solve your problem?

Regards,

António Pereira

Well,

Looking at the query you are missing a vital part.

the solution lies in your question..

you want to see the users clubs and if he/she likes it or not, yet you have no reference at all in the query on the user.


António Pereira wrote:

Hi Karthik,

Do you want to relate the "like" to the user, am I right, i.e. if a user likes a club other user is not forced to also like it? 

If yes, you must associate the user id to the club in the database. A possible solution is to create an entity where each record has an attribute with the User Id and the Id of the Club he liked.

Does it solve your problem?

Regards,

António Pereira

hi antonio,

                   In My Case when one user likes a club it should be saved seperately instead of updating the previous users  liked



      

                        In second screenshot you can see that userid 2 is replaced with userid 9.I want user id 9 to be inserted instead of updating the previous user id 2.

karthik R wrote:

António Pereira wrote:

Hi Karthik,

Do you want to relate the "like" to the user, am I right, i.e. if a user likes a club other user is not forced to also like it? 

If yes, you must associate the user id to the club in the database. A possible solution is to create an entity where each record has an attribute with the User Id and the Id of the Club he liked.

Does it solve your problem?

Regards,

António Pereira

hi antonio,

                   In My Case when one user likes a club it should be saved seperately instead of updating the previous users  liked


With my solution, you'll not update other users like status to a club after another user likes a club since each like is represented by the Club Id and User Id. When you need to get the clubs that a specific user liked, you just add a filter to the query to get only the rows that contain the specific User Id you want.