Single Action Class | Should i make one single action class for frontend & backend
Hello friends thanks for time
I working on e-commerce project I will use single action class for all application
My question | should i make action class from frontend & other one for admin OR use same and pass paramters
For Example
- Frontend/Product/ProductListAction.php
- Admin/Product/ProductListAction.php // ( FOR Dashboard Listing product which is different from front listing query in product page ( in front ) like in selected fields, eager load realtions, filters )
@respect The entire point of creating something like an action class is to prevent duplication.
Given your example, they are two different use cases and therefore shouldn’t be shoe-horned into the same code handling both scenarios. Otherwise your “action class” is just going to end up full if if/else statements and other conditional logic.
@martinbean Scenario like that for example | some times find pages listing products and category only & other page need listing product only (title, and image only) may be in dashboard and other for only title - all fro same model in this case is Product model
What do you mean by one single class?
Are you talking about creating some god class that does everything?
If so, that is a very stupid idea.
Single action controller are a good way to isolate each action, but each model should have the controllers it needs, and a e-commerce application has several models.
@Tray2 Thanks for answer no bro not about controller - it's about 1 class for each action- like create - edit - delete-list - but some times find pages listing products and category only & other page need listing category only (title, and image only) may be in dashboard
MY QUESTION : About make one class to handle all these scenarios because it's from same model product OR Make class for each scenario