I have a simple web application with database tables orders
and products
that I'm reworking with CakePHP. There are more, but for simplicity, I'm using just these two here. In the web app, I'd like to be able to search items, search orders, and do order-related jobs, but I'm having difficulty setting up and choosing components to use to make this web app. As an example to my problem, I have the following page. Check out the layout below.
|------------------------------|
| My App |
|------------------------------|
|Search <--| search order |
|Orders | search product |
|etc. | |
| | |
| | |
|------------------------------|
Figure: left navigation bar and body shown. Arrow denotes page we're on.
Controllers: for this search page, which controllers should be used? I'm defaulting to
PagesController
for static pages right now, but should this search page really usePagesController
? I also haveProductsController
andOrdersController
that were created when I createdProduct
andOrder
models, but it seems more appropriate to use a completely new controller, perhaps one calledSearchController
. This way the URL stays undermyapp/search/...
and doesn't go all over the place. Is this the proper way? (I know I can rewrite URLs, but that's for later)Models and actions: I have
Product
andOrder
models. Each of these models have a search logic for its respective DB table. If a new controller was created for the above page, then that controller can simply use these models' actions right? I'm reading controller and model separation is completely normal and actually a good thing. At first I thought they went together, but the more I familiarize with CakePHP, it seems to be the opposite.If my approach (from 1 and 2) is not inefficient, wrong, or improper, could you suggest a good structure to set this specific page up with respect to what controllers to use and how the controller should be using models and their actions?