Sep 15, 2018
0
Level 1
Access Data from 3 tables based on condition using eloquent orm
I have 3 tables in my Database
Category (id,name,status)
Subcategory(id,parent_category_id,name,status) (parent_category_id is passed as foreign key)
Post (id,title,subcategory_id,status) (sub_category_id passed as foreign key)
Know I want to make a relationship in as per following conditions The conditions are
- whenever the status of category is in_active the child subcategories and posts should not display
- Whenever the status of subcategory is in_active the all the posts having that subcategory_id should not display
- Whenever the post status in in_active that post will not display
I have used hasManythrough relation ship on my Category Model like: hasManyThrough("App\Product","App\Subcategory","parent_category_id","subcategory_id"); But it doesnt gives me the results that I want Is there a better solution ??????
Please or to participate in this conversation.