Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dmytroshved's avatar

Like and Dislike system

Hello

I wanna to create a logic for like/dislike buttons

After watching some materials about this feature I understood I need to create a pivot table, but I am not sure If there an opportunity create one table for those 2 buttons

Should I create two separate pivot tables: recipe_likes & recipe_dislikes OR recipe_socials (with likes and dislikes inside)?

Would be grateful for your help

1 like
5 replies
vincent15000's avatar

In a simple recipe_likes table, you can create these fields.

  • recipe_id
  • user_id
  • like (boolean) // true if like, false if dislike

Don't create two tables, it will be complex to extract any statistics about how many likes and dislikes has a recipe.

You should move your post to the General channel, it's not a Livewire problem.

2 likes
martinbean's avatar
Level 80

@Dmytro_Shved You should use a tiny integer column, and then 1 for likes or -1 for dislikes. That way, you can get the overall sentiment by summing the values.

4 likes

Please or to participate in this conversation.