Tuesday, February 28, 2017

How to select by third table Laravel?

I have Posts table.

Each Post have categories:

Post_categories
 _________________
id post_id | category_id

Also there is table:

User_categories
__________________
category_id | user_id

So, I need to select all rows from Post table, where User_categories.user_id =9 and User_categories.category_id = Post_categories.

So, others words, I need to show articles on that categories user subscribed.




via Darama

Advertisement