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

mstnorris's avatar

Check if relation exists

How do I check if a particular relation exists between two models?

I have two models User and Place I have three tables, users, places and place_user

A User can like many Places and a Place can be liked by many Users.

How do I check if a Place is liked by a particular user?

0 likes
1 reply
pobble's avatar
pobble
Best Answer
Level 3

Create a function in your user model ... likesPlace(place_id)

Please or to participate in this conversation.