How exactly should skinny be a controller? I understand that all models are business models within models, but what about other things.
For example, let's say I wrote a blog site where each user can have multiple posts. Currently, the user will create messages by visiting the message controller and running the create action. Here is a small example of what will happen now.
class Controller_Post extends Controller {
function action_create() {
if ( ! empty($_POST)) {
$post = new Model_Post;
$post->user_id = $this->logged_in_user->id;
$post->values($_POST);
if ( ! $post->create()) {
echo 'Error';
}
else
{
echo 'Saved';
}
}
}
}
My question is what would prevent me from putting the logic higher in the user model, for example.
class Model_User extends Model {
function create_post($post) {
$post = Model::factory('post')->values($post);
$post->user_id = $this->id;
if ( ! $post->create()) {
return FALSE;
}
else
{
return TRUE;
}
}
}
If this were done in this way, the controller would be even smaller than me. This makes more sense to me, because the user is the one who creates the message, so I think that it should be in the user model, and not in the controller.
, Kohana.