Reputation: 127
I have a table for messages (without a controller and model) that users can submit a message to the admin. Aside from creating a messages model and then using loadmodel to search it, is there a better way of doing this?
I would just do something like
//AdminsController
$this->loadmodel('Message');
$this->Message->find(....);
While that is easy to do, I feel like creating a messages model isn't necessary if I can set something up in the Admin model to allow me to do so. Is this possible?
Upvotes: 1
Views: 132
Reputation: 66218
Cake will use an AppModel instance if a model is requested for which there is no model file found. If a model has no associations and follows conventions (plural name, primary key field id
) - then it's not necessary to create a model file at all.
As such the example code in the question will "just work".
Upvotes: 3