vendredi 28 janvier 2022

Is there a way to get Collection of a model and get only objects whose relationship rows exists?

I have three models User, Post and Comment

User
  -id
Post
  -user_id
Comment
  -post_id

My table has issues, for example, some posts are not there or some user rows are not there.

How can I be able to get only comments that have a post_id which exists and it also has a user_id of the user which exists using a scope most preferably global scope?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3o7te1H
via IFTTT

Aucun commentaire:

Enregistrer un commentaire